INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

help with batching a sed script and an awk script

help with batching a sed script and an awk script

(OP)
Hi,



Hi guys :)

I've got both a sed and an awk that I need to run on hundreds of files, each sone works perfectly on a single file, but I need help getting each of them to run in batch mode, here they are:


sed -n 'g;n;p' inputfile.txt | sed '/\,/s/\,//g' > inputfile.out

awk 'NR==FNR{a[$1]=$0;next$3 in a{print $0 a[$1] " " a[$3]}' y.txt x.txt > out.out

actually what would be even better (if there's a way to do it) is to successively batch process:

sed -n 'g;n;p' inputfile1.out | sed '/\,/s/\,//g' > outputfile1.out
sed -n 'g;n;p' inputfile2.out | sed '/\,/s/\,//g' > outputfile2.out
awk 'NR==FNR{a[$1]=$0;next$3 in a{print $0 a[$1] " " a[$3]}' outputfile1.out outputfile2.out > finaloutputfile.txt

can someone help?

Tabitha

RE: help with batching a sed script and an awk script

(OP)
I figured out how to do the batch of the sed sript on both inputfile 1 and 2, can someone please help me with batching the awk script or batching all three.

RE: help with batching a sed script and an awk script

(OP)
the input files look like this

run on
inputfile_A_1.out inputfile_B_1.out > outputfile1.txt
then on
inputfile_A_2.out inputfile_B_2.out > outputfile2.txt
and
inputfile_A_3.out inputfile_B_3.out > outputfile3.txt
like that

thanks sooo much, tabitha

RE: help with batching a sed script and an awk script

Something like this?

CODE

i=1
numfiles=100
while ((i<=numfiles))
do
   dosomething inputfile_A_$i.out inputfile_B_$i.out > outputfile$i.txt
   ((i=i+1))
done 

Annihilannic
tgmlify - code syntax highlighting for your tek-tips posts

RE: help with batching a sed script and an awk script

(OP)
oh great! I'll use this format for later batching stuff, thanks soooo much, Tabitha

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close