1. Find in the -exec Parameters
in the current directory ( including subdirectories ), find all txt files and find the string "Bin" containing the the line
Find./-name "*.txt"-exec grep "bin" {} \;
in the current directory ( including subdirectories ), delete all txt file
Find./-name "*.txt"-exec rm {} \;
Execute command; True if 0 status is returned. All following arguments to find was taken to being arguments to the command until a argument consisting of '; ' Is Encount Ered. The string ' {} ' is replaced by the current file name being processed everywhere it occurs in the arguments to the Comman D, not just in arguments where it is alone.
2. Shell 's built-in command commands exec
#!/bin/ksh
Export Log=/tmp/test.log
EXEC >> $LOG 2>&1
Ls-l Kevin.txt
Exit 0
exec [ARG]
If Arg is present, executes ARG in place of the this shell.
(Arg would replace this shell).
Shell built-in commands exec will not start the new Shell, but instead use the command to be executed to replace the current Shell process, and to clean up the old process environment, and Other commands after the EXEC command will no longer execute.
So, if you're in aShellinside, executeexec lsthen, when the current directory is listed, theShellI quit because of this.Shellthe process has been replaced by just executinglscommand of a process, the execution of the end of nature will quit. To prevent this from affecting our use, we will generallyexeccommand to put in aShellinside the script, the script is called with the main script, which can be used at the call pointBash a.sh, (a.shis the script that holds the command), this willa.shCreate aSub Shellgo to execution, when executed toexec, the sub-script process is replaced with the correspondingexec's command.
Source command or " . ", no new for scripts Shell , but only the commands contained in the script are in the current Shell execution.
However, it is important to note an exception when The exec command does not replace the shell when it operates on the file descriptor , and after the operation is complete, the following commands continue to be executed.
exec 3<&0: This command is the operator 3 also points to standard input.
Original
[1]http://blog.chinaunix.net/uid-20652643-id-1906436.html
[2]http://zhgw01.blog.163.com/blog/static/1041481220098944425489/
[3]http://blog.csdn.net/clozxy/article/details/5818465
[4]http://www.cnblogs.com/zhaoyl/archive/2012/07/07/2580749.html
EXEC command in Shell