Exforsys.com
 
Home Tech Articles UNIX
 

An Introduction to Shell Scripting

 

Basic Definition of Shell Scripting is Storing Frequently Used Commands in Files.

Store the following in a file named simple.sh and execute it.

#!/bin/sh# Generate some useful info for# use at the start of the daydatecallast $USER | head -6

Shows current date, calendar, and a six of your previous logins for security check. You might run this at the beginning of each day.Notice that the commands themselves are not displayed, only the results.To display the commands verbatim as they run, execute with sh -v simple.sh.

To echo the commands after variable translation, execute with sh -x simple.sh

With -v or -x (or both) you can easily relate any error message that may appear to the command that generated it

When an error occurs in a script, the script continues executing at the next command Verify this by changing 'cal' to 'caal' to force an error, and then run the script again Run the 'caal' script with 'sh -v simple.sh' and 'sh -x simple.sh' and verify the error message comes from cal

Now you can re-use commands easily and save some typing and mistakes


Read Next: What is Shell Scripting



 

 

Comments


spshant said:

  The training materials is very limited. It would be a great resource site if Training section is given a little more structured organisation.
Just a thought from a user pov.
Thx,
Prashant
May 17, 2004, 8:18 pm

sanereddy said:

  Thanks Prashanth for your comments. We have added a new section EFS Directory with all the ebooks and tuturials for most of the topics.

Thanks for your comment.
June 19, 2004, 10:01 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2010 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape