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 > 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 12:38 PM
I am one of the newbies, please advise sanlen UNIX for Dummies Questions & Answers 3 09-17-2007 07:45 AM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 10:10 AM
PERL & CPAN Intro for Newbies obitus Tips and Tutorials 0 06-15-2004 09:20 PM
Specially for unix newbies clemeot UNIX for Dummies Questions & Answers 2 09-11-2001 12:16 PM

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 02-07-2006
greenhorn greenhorn is offline
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
  #2 (permalink)  
Old 02-07-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,728
Your question needs some clarification.

$@ returns command line parameters. What exactly are you trying to do?
  #3 (permalink)  
Old 02-07-2006
greenhorn greenhorn is offline
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
  #4 (permalink)  
Old 02-07-2006
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
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 '{
  ...
  }' $@
  #5 (permalink)  
Old 02-08-2006
greenhorn greenhorn is offline
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
  #6 (permalink)  
Old 02-08-2006
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
Like this...
Code:
#!/usr/bin/bash
awk '{
  ...
  }' $(<list.txt)
  #7 (permalink)  
Old 11-17-2008
lost lost is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 24
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!
Closed Thread

Bookmarks

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 11:31 PM.


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