How can I run the same command in mac terminal for multiple files in a folder? The files are named like 24538_7#1.fq, 24538_7#2.fq, 24538_7#3.fq, 24538_7#4.fq and so on.
The commands are:
sed -n '\|@.*/1|{N;N;N;p;}' 24538_7#2.fq > 24538_7#2_paired1.fq
sed -n '\|@.*/2|{N;N;N;p;}' 24538_7#2.fq > 24538_7#2_paired2.fq
Since filename involves a counter, so, obviously the filenames need to be changed.
I was trying to write command, but I got stuck at renaming the file. My effort for the command is below:
for file in 24538_7#*.fq; do sed -n '\|@.*/1|{N;N;N;p;}' "$file" > "${file/fq/fq}"; done
(PS- I use MacOS)
interactive_commentsdisabled) you will need to quote the#to avoid it being interpreted as a comment. – jesse_b May 31 '18 at 18:0624538_7#2.fq > 24538_7#2_paired1.fqis what I want to accomplish but on multiple files as stated earlier. – iamakhilverma May 31 '18 at 18:10