Search This Blog

Showing posts with label grep command ubuntu linux find inside files text. Show all posts
Showing posts with label grep command ubuntu linux find inside files text. Show all posts

Monday, November 25, 2024

To find word inside file linux ubuntu - grep command

If you're looking for lines matching in files, my favorite command is:

grep -Hrni 'vijay' /home/v/abc.txt
grep -rl 'vijay' /home/vfolder

  • -H causes the filename to be printed (implied when multiple files are searched)
  • -r does a recursive search
  • -n causes the line number to be printed
  • -I ignore binary files (complement: -a treat all files as text)
  • -F treat search term as a literal, not a regular expression
  • -i do a case-insensitive search
  • --color=always to force colors even when piping through less. To make less support colors, you need to use the -r option:

    grep -Hrn search . | less -r
    
  • --exclude-dir=dir useful for excluding directories like .svn and .git.

Hit Counter


View My Stats