How to run multiple awk files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run multiple awk files
# 1  
Old 08-06-2009
How to run multiple awk files

I'm trying some thing like this. But not working
It worked for bash files
Now I want some thing like that along with multiple input files by redirecting their outputs as inputs of next command like below
Could you guyz p0lz help me on this

Code:
#!/usr/bin/awk -f
BEGIN
{
}
script1a.awk input1.txt>>output1.txt; awk script1b.awk input2.txt>>output2.txt; awk script2.awk output2.txt output1.txt>>output3.txt; awk script3.awk output3.txt >>FInalOutput.txt


Last edited by repinementer; 08-06-2009 at 07:30 AM..
# 2  
Old 08-06-2009
You cannot do that inside an awk program.
Do it inside a bash script
Code:
#!/usr/bin/bash
awk -f script1a.awk input1.txt>>output1.txt  && \
awk -f script1b.awk input2.txt>>output2.txt  && \
awk -f cript2.awk output2.txt output1.txt>>output3.txt && \ 
awk -f script3.awk output3.txt >>FInalOutput.txt

Jean-Pierre.
# 3  
Old 08-07-2009
hi

I'm getting error like this
Code:
$ awk -f Annotator.awk
awk: Annotator.awk:2: awk -f script1a.awk input1.txt>>output1.txt  && \
awk: Annotator.awk:2:                ^ syntax error
awk: Annotator.awk:3: awk -f script1b.awk input2.txt>>output2.txt  && \
awk: Annotator.awk:3:                ^ syntax error
awk: Annotator.awk:4: awk -f script2.awk output2.txt output1.txt>>output3.txt &&
 \
awk: Annotator.awk:4:               ^ syntax error
awk: Annotator.awk:4: awk -f script2.awk output2.txt output1.txt>>output3.txt &&
 \
awk: Annotator.awk:4:



---------- Post updated at 07:42 PM ---------- Previous update was at 07:37 PM ----------

Code:
$ sh Annotator.sh
Annotator.sh: line 2:  awk: command not found

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Run sed and awk in multiple files in adirectory

Dear linux users I was running around of 200 djob for a Blastp search in a cluster. All my input files were protein fasta file (prot.fna.1, prot.fna.2 ...prot.fna.200). The output of each individual slurm job is located in a corresponding file ending with *test (prot.fna.1.test,... (10 Replies)
Discussion started by: Dieunel
10 Replies

2. UNIX for Dummies Questions & Answers

Run script on multiple files

Hi Guys, I've been having a look around to try and understand how i can do the below however havent come across anything that will work. Basically I have a parser script that I need to run across all files in a certain directory, I can do this one my by one on comand line however I... (1 Reply)
Discussion started by: mutley2202
1 Replies

3. Shell Programming and Scripting

How to use a loop for multiple files in a folder to run awk command?

Dear folks I have two data set which there names are "final.map" and "1.geno" and look like this structures: final.map: gi|358485511|ref|NC_006088.3| 2044 gi|358485511|ref|NC_006088.3| 2048 gi|358485511|ref|NC_006088.3| 2187 gi|358485511|ref|NC_006088.3| 17654 ... (2 Replies)
Discussion started by: sajmar
2 Replies

4. Shell Programming and Scripting

Run script on multiple files

I have a script that I need to run on one file at a time. Unfortunately using for i in F* or cat F* is not possible. When I run the script using that, it jumbles the files and they are out of order. Here is the script: gawk '{count++; keyword = $1} END { for (k in count) {if (count == 2)... (18 Replies)
Discussion started by: newbie2010
18 Replies

5. Shell Programming and Scripting

Run one script on multiple files and print out multiple files.

How can I Run one script on multiple files and print out multiple files. FOR EXAMPLE i want to run script.pl on 100 files named 1.txt ....100.txt under same directory and print out corresponding file 1.gff ....100.gff.THANKS (4 Replies)
Discussion started by: grace_shen
4 Replies

6. UNIX for Dummies Questions & Answers

Run one script on multiple files and print out multiple files.

How can I run the following command on multiple files and print out the corresponding multiple files. perl script.pl genome.gff 1.txt > 1.gff However, there are multiples files of 1.txt, from 1----100.txt Thank you so much. No duplicate posting! Continue here. (0 Replies)
Discussion started by: grace_shen
0 Replies

7. Shell Programming and Scripting

Bash Scipting (New); Run multiple greps > multiple files

Hi everyone, I'm new to the forums, as you can probably tell... I'm also pretty new to scripting and writing any type of code. I needed to know exactly how I can grep for multiple strings, in files located in one directory, but I need each string to output to a separate file. So I'd... (19 Replies)
Discussion started by: LDHB2012
19 Replies

8. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

9. Shell Programming and Scripting

How to run awk command having multiple lines

Hi, Can u see the code below. set xyz = `cat testt1.txt | awk '/-----/{\ print $1 }\ ' | tail -1` I need to execute it in c shell . What is wrong with the above command. When i write everything on a single line then it is working. Can anybody help me . (0 Replies)
Discussion started by: nani_g
0 Replies

10. UNIX for Dummies Questions & Answers

when I try to run rm on multiple files I have problem to delete files with space

Hello when I try to run rm on multiple files I have problem to delete files with space. I have this command : find . -name "*.cmd" | xargs \rm -f it doing the work fine but when it comes across files with spaces like : "my foo file.cmd" it refuse to delete it why? (1 Reply)
Discussion started by: umen
1 Replies
Login or Register to Ask a Question