Shell Programming - Western University
Shell Programming
Shell Scripts (1)
u Basically, a shell script is a text file with Unix commands in it.
u Shell scripts usually begin with a #! and a shell name
? For example: #!/bin/sh ? If they do not, the user's current shell will be used
u Any Unix command can go in a shell script
? Commands are executed in order or in the flow determined by control statements.
u Different shells have different control structures
? The #! line is very important ? We will write shell scripts with the Bourne shell (sh)
Shell Scripts (2)
uWhy write shell scripts?
? To avoid repetition: vIf you do a sequence of steps with standard Unix commands over and over, why not do it all with just one command?
? To automate difficult tasks: vMany commands have subtle and difficult options that you don't want to figure out or remember every time.
A Simple Example (1)
u tr abcdefghijklmnopqrstuvwxyz \ thequickbrownfxjmpsvalzydg < file1 > file2
? "encrypts" file1 into file2
u Record this command into shell script files:
? myencrypt #!/bin/sh tr abcdefghijklmnopqrstuvwxyz \
thequickbrownfxjmpsvalzydg ? mydecrypt #!/bin/sh tr thequickbrownfxjmpsvalzydg \
abcdefghijklmnopqrstuvwxyz
A Simple Example (2)
uchmod the files to be executable; otherwise, you couldn't run the scripts
obelix[3] > chmod u+x myencrypt mydecrypt
uRun them as normal commands:
obelix[4] > ./myencrypt < file1 > file2 obelix[5] > ./mydecrypt < file2 > file3 obelix[6] > diff file1 file3
Remember: This is needed when "." is not in the path
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- 4 cadence incisive enterprise simulator support
- command line scripting 2
- programmation shell sous unix linux sh bourne ksh bash 3iã â me ã â
- linux sh documentation 呆鸥
- how to run shell script in command prompt
- scripts shell linux et unix avec 30 scripts prã âªts ã â l emploi
- using unix shell scripting to enhance your sas programming experience
- linux execute sh file
- bash shell scripting for helix and biowulf nih hpc systems
- linux sh file example
Related searches
- western illinois university online degree
- western illinois university majors
- western illinois university online degrees
- university of western illinois
- western illinois university degree programs
- university western australia masters program
- western washington university teaching certificate
- western university pa program california
- western university pa program prerequisites
- western university graduate program
- western colorado university athletics
- western university health science pa program