bash - How to make my program take multiple std inputs and give multiple std outputs in return? -
i able write program takes input "file.txt" containing type of strings atcgtaattc , gives output second file called "compl-file.txt" containing caattacgat. of works well, need program take many files inputs , give many compl-files outputs while applying processes. thank !
#! /usr/bin/bash # ##create file called compl-* name=`echo $1 | sed -e 's/\(.*\)/compl-\1/'` touch $name ##upside down var1=$(tac < $1) echo "$var1" > $name ##reverse var2=$(rev $name) echo "$var2" > $name ##replace g/c c/g var3=$(sed -e 's/c/x/g; s/g/c/g; s/x/g/g' $name) echo "$var3" > $name ##replace a/t t/a var4=$(sed -e 's/a/y/g; s/t/a/g; s/y/t/g' $name) echo "$var4" > $name
many filenames can given parameters. can process each 1 @ time:
for name # process filename here "$name" (put filename in double quotes) done as output filenames, there several ways of identifying them. add counter end of filename, date/time stamp, or use input filename , append "-compl" end. depends how need identify each one.
by way, in code continually overwrite file, want >> "$name" append.
Comments
Post a Comment