EXEC command in Linux
Hi
Can anybody tell me what is the use of EXEC command and how we can use it, i checked online but still have confusion with this. like in this below command what EXEC will do : find . -type f -name "*19201020320*" -exec cp '{}' /tmp \; Thanks in advance |
|
Quote:
There's also a command called exec (16.1. Using exec (ABSG)) |
It will execute a copy command of the found files into the /tmp directory. Termination of the exec command is the \; sequence. My more common usage is this, although I'm sure there are newer commands which can do similar results.
Code:
find . -name "*.[ch]" -exec grep <pattern> {} /dev/null \; And I don't know the full explanation, but without the /dev/null, I get the grep results only and don't see the files which they are located in. With the /dev/null, I get the found files, including fully resolved pathnames; which is more useful. Further I'm not sure EXEC is a shell command, but instead solely an extension to the find(1) command. Given the example you cited, this is the best guess, which other's have also responded too. But also realize that there is a family of exec(3) functions which are used in programs to execute commands. A bit lengthy, and covers way more than the fundamentals for exec(), but here are some notes on what that's used for: http://www.linuxquestions.org/questi...ocesses-35540/ |
Quote:
|
The -H option prints the filename and the matching lines. If you want the filename only, use the -l option.
I just finished posting more details about using find and grep in the OP's other thread about listing folders. |
All times are GMT -5. The time now is 11:31 PM. |