Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: 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

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    A possible solution :
    Code:
    cat text_file | xargs softwareupdate -i
    Jean-Pierre.

  3. #3
    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 !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •