If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > extract variable text from file and push to command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-15-04, 15:24
snowcrash_nz snowcrash_nz is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
extract variable text from file and push to command

Hi

I need to get the contents of a text file into an executable command.
The text file might read:

iCal-1.5.2
iSync-1.4
iTunes4-4.2
MacOSXUpdate10.3.2-10.3.2

I need the command to read

softwareupdate -i iCal-1.5.2 iSync-1.4 iTunes4-4.2 etc ...

I can do it quite manually but need a script that will execute no matter how many entries are in the text file (there might be 1 or 20). The text of the file would vary each time also (different installs).
Thanks
Reply With Quote
  #2 (permalink)  
Old 03-15-04, 15:47
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
A possible solution :
Code:
cat text_file | xargs softwareupdate -i
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 03-15-04, 16:01
snowcrash_nz snowcrash_nz is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks !!!!

have never used the xargs command but it works a treat. At this stage I just needed the command to print not execute as I'm sitting on Linux and it needs to run on OS X. I modified it to read:

Installs=`cat /tmp/temp.txt | xargs echo`
echo "softwareupdate -i $Installs"

Much appreciate that as it was driving me batty !!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On