Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Bioprogrammer

macrumors newbie
Original poster
May 16, 2011
2
0
Hi,

I'm new to programming. I've written some scripts in awk and want to make a batch file or program to run these scripts reading one file and naming new files depending on the scripts that were used.

These are 2 examples of different scripts I'm using.
awk '{if($2 == 64 || $2 ==128){print $0}}' filein.sam > fileout64or129.sam
awk '{if($2 == 65 || $2 ==129){print $0}}' filein.sam > fileout65or129.sam

This is the file I made today and it is running one the awk script (I can see it in top), but doesn't seem to create a file I can find. (This file doesn't include the second awk script, I seem to have a problem naming the files rather than running the program or awk commands)

echo Enter file name
read NAME
awk '{if($2 == 65 || $2 ==129){print $0}}' $NAME > $NAME65or129.sam


What I would like to do is be able to type in the name of the file (filein.sam), have it run both scripts and name the output files fileout64or129.sam, fileout65or129.sam, or fileout(some flag).sam.

Thanks
 
I'm not totally sure what you want to do or what problem you're currently having. Is the awk piece working properly but your shell script is not? Do you want to strip .sam before naming your output file?

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.