Find the answer to your Linux question:
Results 1 to 1 of 1
Hi all, I am scripting in bash, I call another program, and then I want to touch files that have the name and timestamp of my grep output (the 2 ...
  1. #1
    Just Joined!
    Join Date
    Sep 2008
    Location
    Washington DC
    Posts
    5

    Putting together xargs and touch

    Hi all,

    I am scripting in bash, I call another program, and then I want to touch files that have the name and timestamp of my grep output (the 2 and 3 arguments respectively). I have a work around where I use awk, and then put it into xargs, but I think there should be a way to put it into xargs directly. Additionally my current way seems to be slow, probably because I am opening so many shell processes. I think I should be able to replace awk|xargs with a single xargs because I know xargs has awk-like capabilities. I am just not that familiar with xargs.

    #! /bin/bash
    ../fametouch-prog.sh $1 | fame -nomsg -d .\
    | grep SERIESTS \
    | awk '{ printf "touch -t " $3 " " $2 "\n" }' \
    | xargs -I {} -i sh -c '{}'


    The first line of the script (or 2nd if you count /bin/bash) is just calling the other software and producing some output.

    So I guess I end up with 3 questions, is a single xargs going to be significantly faster? Is it possible? and any help on how to do it would be appreciated.

    Thanks.
    Last edited by bdlbfrb08; 06-26-2009 at 08:30 PM. Reason: clarification

Posting Permissions

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