Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology

Similar presentations


Presentation on theme: "Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology"— Presentation transcript:

1 Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology hoai@cse.hcmut.edu.vn

2 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Redirection (1) “ > ” redirect input Ex: $ cat aaa.txt Sends the content of “ aaa.txt ” to stdout (normally screen) $ cat aaa.txt > bbb.txt Sends the content of “ aaa.txt ” to “ bbb.txt ” or copy file “ aaa.txt ” to a new file “ bbb.txt ”

3 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Redirection (2) “ < ” redirect input Ex: hello.c #include int main( int argc, char *argv[] ) { double d; scanf( "%lf", &d ); printf( "My input number: %lf\n", d ); return 0; }

4 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Redirection (3) $ hello 10005.6 My input number: 10005.6 $ hello < aaa.txt My input number: 10006.5 $

5 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Appending to file “ >> ” appending to file Ex: $ cat aaa.txt >> bbb.txt Appends the content of “ aaa.txt ” to the end of “ bbb.txt ”

6 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Pipe Connect several commands together UNIX commands get input from stdin and pass output to stdout “|” directs UNIX to connect stdout from the first command to the stdin of the second command

7 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Pipe (2) Ex: $ cat aaa.txt | more Sends the content of “ aaa.txt ” to command “ more ” $ ls * | grep pdf Lists all files and choose only files which have pattern “ pdf ”

8 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Pipe (3) $ ls /usr/bin/ | grep pdf | wc –l “ wc –l ” count the number of lines The whole command counts the number of ? files in “/usr/bin” having a pattern “pdf” in names

9 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Other symbols &Run in background (daemon) ~Home directory " Partial quote (variable/command expansion) ' Full quote (no expansion) $varValue of variable $$Process Id $nnth argument ($0=command) $*All arguments *,?Wildcard characters

10 Dr. Tran, Van Hoai 2007 Advanced UNIX Shell Basic shell script programming is NEXT


Download ppt "Advanced UNIX Shell Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology"

Similar presentations


Ads by Google