The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-07-2006
Registered User
 

Join Date: Feb 2006
Posts: 6
Smile Newbies problem

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
Reply With Quote
Forum Sponsor
  #2  
Old 02-07-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Your question needs some clarification.

$@ returns command line parameters. What exactly are you trying to do?
Reply With Quote
  #3  
Old 02-07-2006
Registered User
 

Join Date: Feb 2006
Posts: 6
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
Reply With Quote
  #4  
Old 02-07-2006
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
You could use a for loop, e.g....
Code:
#!/usr/bin/bash
for i
do
   : some command using $i
done
...but if you are using awk, then you can just use...
Code:
#!/usr/bin/bash
awk '{
  ...
  }' $@
Reply With Quote
  #5  
Old 02-08-2006
Registered User
 

Join Date: Feb 2006
Posts: 6
Smile

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
Reply With Quote
  #6  
Old 02-08-2006
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Like this...
Code:
#!/usr/bin/bash
awk '{
  ...
  }' $(<list.txt)
Reply With Quote
  #7  
Old 2 Weeks Ago
Registered User
 

Join Date: Sep 2008
Posts: 14
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!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0