first of misc questions....

Derek Ragona derek at computinginnovations.com
Wed Apr 25 11:23:40 UTC 2007


At 02:29 AM 4/25/2007, Gary Kline wrote:
>         Guys,
>
>         This is an awk-type question.  Hopefully a one-liner.  If I
>         need to use #!/usr/bin/awk and a BEGIN/END (or whatever it is),
>         that's okay...
>
>         I want to do an ls -l in a  /home/kline/<directory> and find and
>         edit files that are dated (let's say) Apr 19 or Mar 26.  This
>         works to print $9 the filenames.
>
>         ls -l| awk '{if ($6 == "Apr" && $7 == 19  || $6 == "Mar" && $7
>         == 26 ) print $9}'
>
>         What's the final part to get awk to vi $9?  Or another pipe and
>         xargs and <what> "vi"?  Nothing simple works, so thanks for any
>         clues!

I would use a simple approach incase you need to re-edit the list since 
editing will change file times:
ls -l| awk '{if ($6 == "Apr" && $7 == 19  || $6 == "Mar" && $7 == 26 ) 
print $9}' > /tmp/myfilelist
then you can:
for i in `cat /tmp/myfilelist`;do vi $i;done

if you don't want to use a file, you can do in one shell loop too, but 
again this will change your file modification times:
for i in `ls -l| awk '{if ($6 == "Apr" && $7 == 19  || $6 == "Mar" && $7 == 
26 ) print $9}'`;do vi $i;done

         -Derek

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.



More information about the freebsd-questions mailing list