How would I change the following command in Unix so it does the same thing except it directs the output to a file (it can create one or use an existing file, doesn't really matters) rather than displaying the results on the sceen.
find . -name *.fmb -exec grep -l "Output" {} 2%26gt;/dev/null \;
Unix Find directed to file for output?
Use this.
If you want to write to a file and overwrite everything else in the file.
find . -name *.fmb -exec grep -l "Output" {} 2%26gt;/dev/null \; %26gt; filename
If you don't want to overwrite evrything and just want to append the output to the file.
find . -name *.fmb -exec grep -l "Output" {} 2%26gt;/dev/null \; %26gt;%26gt; filename
Reply:at the end of the line put %26gt; filename
Reply:standard redirection with the '%26gt;' symbol,
i.e.
find /var/tmp -name 'somefile*' -exec grep 'somepattern' /dev/null {} \; %26gt; /tmp/outputfile
%26gt; will create a new file or over-write an existing one
%26gt;%26gt; will append to an existing file
Note: if you use grep with find, you will not see the file
name that the pattern is found in, unless you include an
additional file name argument to grep (assuming gnu grep
or most modern grep implementations)
Reply:find "xx" %26gt;%26gt; file
or
cat %26lt;%26lt; find "xx" %26gt;%26gt; file
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment