Use a command to create a directory tree
~ $ Mkdir-P tmp/A/B/C
Use a command to define a complex directory tree
~ $ Mkdir-P project/{lib/EXT, bin, SRC, DOC/{HTML, info, PDF}, demo/STAT/}
Use Option-C to decompress the. tar archive file to the specified directory.
~ $ Tar xvf-C tmp/A/B/C newarc.tar.gz
Execute multiple commands in sequence
~ $ CD/; LS-l
Condition | control the execution of multiple commands
(If the tmp/A/B/C directory does not exist, the CD command returns a non-0 value and continues executing the mkdir command)
~ $ CD tmp/A/B/C | mkdir-P tmp/A/B/C
Condition & control execution of multiple commands
(When the tmp/A/B/C directory exists, the CD command returns 0 and continues to execute the tar command)
~ $ CD tmp/A/B/C & tar xvf ~ /Archive.tar
Use subshell to run the command list
(Use parentheses to include the command list in a single group. This will run the command in a new subshell and allow you to redirect or collect the output of the entire group of commands)
~ $ (CD tmp/A/B/C/| mkdir-P tmp/A/B/C &&/
> Var = $ PWD; Cd ~; Tar xvf-C $ var archive.tar )/
> | Mailx admin-s "ARCHIVE contents"
Execute commands using xargs Batch Processing
(The list of log files output by the previous command LS is run one by one as the input parameters of the next command file)
~ $ Ls/var/logs/*. log | xargs File
/Var/log/Anaconda. Log: UTF-8 Unicode English text
/Var/log/boot. Log: empty
/Var/log/prelink. Log: ASCII English text
/Var/log/scrollkeeper. Log: UTF-8 Unicode text
/Var/log/xorg.0.log: ASCII English text
/Var/log/yum. Log: empty
Use awk to separate text files
(The separator is used here)
~ $ Echo 2009/09/09> test.txt
~ $ Awk-F/'{print $1, $2, $3}' test.txt
2009 09
(Refer to some articles on IBM developerworks)