简体   繁体   中英

If I grep recursivley through a directory, how can i save the resulting output to a simple .txt file?

So for example, if I used the command:

grep -r "search" *

could I use a command to save the resulting output to a .txt file?

grep -r "search" * > somefile.txt

This kind of redirection is not specific to the command you are running, by the way. It is a feature of the command shell. The standard shell in linux is called bash. man bash should give you more information than you probably want, but look for the section called REDIRECTION for a comprehensive discussion of these features.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM