Sponsored Links

 

 

 

UNIX System Programming

Source: csserver.evansville.edu
Topic: Shell Programming


Short Desciption:
UNIX System Programming Lecture 4 BASH Shell Programming BLP: Chapter 2 BABS Outline: Redirection ... zsh, ksh Change your default shell to bash $ chsh -s /bin/bash 2 Our First Shell Script A ...

 

Content Inside:
UNIX System Programming Lecture 4 BASH Shell Programming BLP: Chapter 2 BABS Outline: Redirection Shell Programming Introduction The shell is a command interpreter and a full- featured programming language.  It is especially well-suited for system administration and for file, directory and process management. Several different shells are available: sh, bash, csh, zsh, ksh Change your default shell to bash $ chsh -s /bin/bash 2 Our First Shell Script A hello world example $ cat > hello #! /bin/bash # Prompt user for name echo -n "Enter your name: " read name echo Hello there $name! exit 0 $ chmod +x hello $ . /hello Enter your name: Elmer Fudd Hello there Elmer Fudd! $ 3 Our First Shell Script Start with a sha-bang (#! ) .  The kernel will automatically pass the script to the proper interpreter.  End with ìexit 0î (or non-zero exit to indicate an error condition) . Comments begin with a # Make the script executable and run it like a standard program OR you can also run the program like this: $ bash hello# run in new env (like . /hello) $ . hello # run in same env (also source hello) 4 Wildcards (globbing) Wildcard expansion is done by the shell.  Not by the application. A * matches any character except a leading dot (. ) .  A ? matches any single character. $ echo * a. 1 b. 1 c. 1 t2. sh test1. txt $ ls t? . sh t2. sh $ ls [a-c]* a. 1  b. 1  c. 1 $ ls {b*, c*, *est*} b. 1  c. 1  test1. txt $ ls *. {1, sh} a. 1  b. 1  c. 1  t2. sh 5 Redirection Every program automatically has three files/streams available: standard input, standard output, and standard error. In C, the FILE* streams are stdin, stdout, and stderr. In C++, the IO streams are cin, cout, and cerr. By default, they are connected to the keyboard, the display, and the display but they can be redirected. 6 Redirection Heres ...

 

add to Google Reader add to Google Bookmark add to bloglines add to newsgator add to FURL add to digg add to webnews add to Netscape add to Yahoo MyWeb add to spurl.net add to diigo Bookmark newsvine Bookmark del.icio.us Bookmark @ SIMPIFY Bookmark MISTER WONG Bookmark Linkarena Bookmark icio.de Bookmark oneview Bookmark folkd.com Bookmark yigg.de Bookmark reddit Bookmark StumbleUpon Bookmark Slashdot Bookmark blinklist Bookmark technorati add to blogmarks add to blinkbits add to ma.gnolia add to smarking.com add to netvouz add to co.mments add to Connotea add to de.lirio.us

 

Related PDF Files

basic shell programming


Topic: Shell Programming

bash derives much of its programming functionality from shell variables. Weve ... builtin variables that are vital to shell programming. ...

Unix POSIX Shell Programming SVR4


Topic: Shell Programming

Unix POSIX (Korn) Shell Programming SVR4. Course Outline. UNIX Shells and Shell Scripts. Describe the role of shells in the UNIX environment ...

Bourne Shell Programming in One Hour


Topic: Shell Programming

Shell programming is also different from conven. tional programming languages. For example the. shell itself doesnt provide much useful functionality; ...

GUIfying and Documenting your Shell Script


Topic: Shell Programming

plications and are meant to achieve a higher level of programming. ... shell script itself (or any application of choice with a specified CLI) can be ...

Linux Shell Scripting Tutorial


Topic: Shell Programming

shell programming by showing some examples of shell programs. Its not help or ... Before Starting Linux Shell Script. Programming you must know ...

 

Sponsored Links