The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-13-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
The positional parameters are in $1 $2 $3 etc but if you are invoking the script with redirection, there is no positional parameter, and no file name, just standard input.


Code:
vnix$ ./myscript file.txt oops   #  inside myscript, $1 is "file.txt" and $2 is "oops"
vnix$ ./myscript   # inside myscript, no file name is known; input is from standard input (terminal)
vnix$ ./myscript <file.txt   # again, inside myscript, no file name is known; input is redirected to come from file.txt


Last edited by era; 05-13-2008 at 09:02 AM.. Reason: Add enlightening (?) example