![]() |
|
|
|
|
|||||||
| 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 |
| What kind of Linux for the newbies? | sanlen | UNIX for Dummies Questions & Answers | 2 | 10-01-2007 09:38 AM |
| I am one of the newbies, please advise | sanlen | UNIX for Dummies Questions & Answers | 3 | 09-17-2007 04:45 AM |
| problem with dd command or maybe AFS problem | Anta | Shell Programming and Scripting | 0 | 08-25-2006 07:10 AM |
| PERL & CPAN Intro for Newbies | obitus | Tips and Tutorials | 0 | 06-15-2004 06:20 PM |
| Specially for unix newbies | clemeot | UNIX for Dummies Questions & Answers | 2 | 09-11-2001 09:16 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi
I am new to Unix and need help. How do I use the $@ in my script to direct the executing of commands on various files. Thanks curious greenhorn |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Your question needs some clarification.
$@ returns command line parameters. What exactly are you trying to do? |
|
#3
|
|||
|
|||
|
Newbies
Sorry for my unclear query earlier
Recently, I read something about the variable $@ but do not really know how to use it. My problem is as follows: I have written a script such as: #!/bin/bash awk ' {.... }' I would like to execute this script on afew datafiles, with different names ( .txt). How can I use $@, so that it automatically execute the commands on all files, one after another? Hope you can help! Thanks cheers curious greenhorn |
|
#4
|
||||
|
||||
|
You could use a for loop, e.g....
Code:
#!/usr/bin/bash for i do : some command using $i done Code:
#!/usr/bin/bash
awk '{
...
}' $@
|
|
#5
|
|||
|
|||
|
Hi
Thank you for your explanation. If I were to use the awk version and end it with $@, how can I execute the command to a list of filenames (I have numereous files and have listed the names in a list.txt file)? curious grennhorn |
|
#6
|
||||
|
||||
|
Like this...
Code:
#!/usr/bin/bash
awk '{
...
}' $(<list.txt)
|
|
#7
|
|||
|
|||
|
Hey..
I've used the above to make this: #!/usr/bin/bash args 2,5 $(<file.list) and it works but I'll like the results separated into different files or back into the used files. e.g. use fileA | args 2,5 > fileB or fileA and then do this to 50 files. Is there an easy way? Thanks! |
|||
| Google The UNIX and Linux Forums |