Monday, October 22, 2012

Search for a string in files in SunOS

The problem seems to be very easy to google for but many options for grep I was able to find didn't work for me. So if you want to get a list of file names containing some specific string in SunOS or Solaris you can use this command:

find . -type f | xargs grep -l "<string to search>"

use this if you want to ignore access/file read errors:

find . -type f 2>/dev/null | xargs grep -l "<string to search>"  2>/dev/null


1 comment:

  1. Yeah, recently I learned about xargs command. Very useful :)

    ReplyDelete