![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Passing more than one argument in a function | jisha | Shell Programming and Scripting | 1 | 04-23-2008 03:05 AM |
| How to pass variables to FUNCTION ? | bh_hensem | Shell Programming and Scripting | 5 | 05-30-2007 11:54 PM |
| How do I pass a wild card as an argument | eja | UNIX for Dummies Questions & Answers | 2 | 03-28-2007 11:03 AM |
| Passing Argument to Function | AkumaTay | UNIX for Dummies Questions & Answers | 2 | 10-18-2001 03:24 PM |
| pass argument to a filename | jpprial | UNIX for Dummies Questions & Answers | 1 | 09-03-2001 12:12 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Pass argument to function
Hi,
Can someone please explain to me how I can get a function to recognize a file given as an argument to a script. Suppose the script has the argument as follows: sh script file and the function is as follows: function display_file () { cat $1 } and it s then called #main program display_file I find that the only way that I can get the file into the function is to make a copy in the main program like so: cp $1 temp I have read some lit on functions but haven't come accross this type of problem as far. Thanks in advance, Knotty. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
It's alright folks,
after messing about with the script a bit I figured it out. Just use the positional parameter as an argument to the function as so: display_file $1 |
|||
| Google The UNIX and Linux Forums |