Monday, July 27, 2015

grep command

grep can be used to match literal string in text file
  • #grep "string" full_file_name
print string but except '#' char at first line and remove blank lines
  • #grep -v "^$\|^\s*[#]" full_file_name
find string in file
  • find . -name '*.*' -exec grep -i 'string to search for' {} \; -print
and then compress files
  • find /path/ -name "pattern" -type f -exec tar -rvf {} +
  • find /path/ -name "pattern" -type f -print0 | xargs tar cvf compress.tar 

No comments: