Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with batching a sed script and an awk script

Status
Not open for further replies.

atjurhs

Programmer
Aug 10, 2012
18
0
0
US
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
 
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.
 
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
 
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
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
oh great! I'll use this format for later batching stuff, thanks soooo much, Tabitha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top