The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Simple rm commands in my server chickenhouse Shell Programming and Scripting 4 02-24-2008 11:14 PM
need help with understanding and modifying script dakkorn Shell Programming and Scripting 4 01-24-2008 09:01 AM
Modifying a csv file from Shell Script not4google Shell Programming and Scripting 2 11-21-2006 06:47 AM
simple Unix commands i don't care UNIX for Dummies Questions & Answers 2 08-16-2002 11:09 AM
simple commands aningsabah UNIX for Dummies Questions & Answers 1 10-19-2001 09:20 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-03-2007
rocinante rocinante is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
Modifying simple commands to create a script

Can anyone direct me to a resource that explains scripting in simple terms?
I have visited many sites and browsed this forum and have yet to find simple explanations.
  #2 (permalink)  
Old 06-03-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
1. Start with "#!/bin/sh" or whatever shell you want to use.

2. Put whatever commands you want in the script. Which are the same as what you can type at the command line.

3. make it executable with chmod +x

4. "man sh" is the ultimate resource

Which is rather like saying to play the flute you blow at one end and move your fingers over the holes.

Code:
#!/bin/sh
# that comment is picked up by exec() and causes this script to be run by /bin/sh

echo this is a script

for d in a b c
do
     echo $d
done
  #3 (permalink)  
Old 06-03-2007
rocinante rocinante is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
Thank You Porter..

I understand a bit more about this after reading your post.

Do you know of any resources that give step by step explanations using visuals?
  #4 (permalink)  
Old 06-03-2007
aigles's Avatar
aigles aigles is online now Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,417
Some links ...
Shell Scripting Tutorial (Beginner-Intermediate)
Bourne Shell Programming
Advanced Bash-Scripting Guide
BASH Programming - Introduction HOW-TO

Jean-Pierre.
  #5 (permalink)  
Old 06-03-2007
rocinante rocinante is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
Thank You Jean-Pierre

These links look good.
If I have any further questions can I refer them to you?
  #6 (permalink)  
Old 06-03-2007
rocinante rocinante is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 21
How should the txt file be formatted and named?

Okay, so I have a small script ( my first ) and want to know what the proper formatting is ? Should the .txt file be saved in the bin folder?
How does it become an executable?
  #7 (permalink)  
Old 06-03-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
it is traditionally either

(a) a file with no extension, eg "foo"

(b) a file with .sh as the extension, such as "foo.sh"

(c) a file with the type of shell as the extension, eg "foo.ksh"

It can live anywhere or on the PATH. You can say ./foo.sh or myfoo/foo.sh etc.

To make it executeable use "chmod +x foo.sh" to change the executable rights.
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0