Pages tagged with grep

I'm still in the process of tagging pages that were migrated from the old site, so for now you're best off using the search engine rather than relying on the tags.

  • Find files containing a pattern - You can find files with grep or find with grep. Using grep grep -riHn [pattern] . This will recursively find all files under the current directory (and it’s subdirectories) that contain the given pattern. The flags are as follows: r recursive...
  • Find and replace - Notes on how to use the find command to find and replace text. Index Delete everything up to the first occurence of a regexp Keep everything between <START> and <END> Find and replace over multiple lines with sed Find and replace ...
  • Find notes - Notes on the Linux find command. Index Find multiple file names Find ignoring a file Find ignoring a file and a directory Find files with particular permissions Find files not owned by a particular user or group Change extension of multip...
  • Extract filenames from file - grep for word in file | remove spaces | remove unwanted text | do op on file grep whatever whatever.log | sed 's/ /\\ /g' | sed 's/whatever//g' | xargs ls -l Example: List infected files clamscan -r -lclamscan.log / recursively scans all files and...
  • Grep notes - Some notes on grep, the pattern matching program found on most Linux distributions. Show partial lines on match Grep doesn’t have an option to show leading/trailing characters before/after the match. Instead you have to prevent it returning the entir...

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top