#!/bin/bash
#check to see if there is an input file:
if [ "$#" -lt 1 ]
then
echo "Usage: $0 input_file ..."
exit 1
fi
#Check if the file is empty or not
file=$1
if [[ -s $1 ]] # if not empty:
then
echo ""
echo "**** $file has data."
cat $1 | sed 's/>/\n>/g' > temp1.txt
cat temp1.txt | sed '/^>/ d' > temp2.txt
awk '!NF{if(++n <=1) print; next}; {n=0; print}' < temp2.txt > dna.out
awk '/./{printf "%s",$0;next} {print "\n";} END{if (/./)print""}' dna.out > DNA.out
echo "**** Number of DNA sequences:"
grep -cve '^\s*$' DNA.out
echo "**** Mumber of empty lines:"
grep -ce '^\s*$' DNA.out
echo ""
#Remove duplicate empty lines:
awk '!NF{if(++n <=1) print; next}; {n=0; print}' < temp2.txt > DNA.out
echo "**** DNA.out created (removed FASTA header)"
#convert to mRNA and remove temp1, temp2 to avoid confusion
tr ACGT ACGU < DNA.out > RNA.out
echo "**** RNA.out created (T -> U)"
echo ""
rm temp1.txt temp2.txt
moved to conversion:
while read rna; do
aawork=$(echo "${rna}" | sed -n -e 's/\(...\)\1 /gp' | sed -f rna.sed)
echo "$aawork" | sed 's/ //g'
echo "$aawork" | tr ' ' '\012' | sort | sed '/^$/d' | uniq -c | sed 's/[ ]*\([0-9]*\) \(.*\)/\2\
: \1/'
done
echo "**** creating AminoAcid from DNA:"
./convert_dna.sh < DNA.out > DNA_AminoAcid.out
echo "**** Amino Acids from DNA saved in DAN_AminoAcid.out."
echo "**** creating AminoAcid from RNA:"
./convert_rna.sh < RNA.out > RNA_AminoAcid.out
echo "**** Amino Acids from RNA saved in RAN_AminoAcid.out."
echo ""
else # if the file is empty.
echo "**** $1 has no data, or file does not exist."
echo "**** done!"
echo ""
#clean the FASTA file and remove all lines starting with >, adding a new line first to avoid mixing all DNA samples:
fi;
convert_dna.sh and convert_rna.sh are two scripts that contain the while loop I mentioned in my first post. One with dna.sed and the other with rna.sed.
My question is how to add the while loop two times one with the dna.sed and the other one with rna.sed.
I have multiple input files that I want to manipulate using a shell script. The files are called 250.1 through 250.1000 but I only want the script to manipulate 250.300 through 250.1000. Before I was using the following script to manipulate the text files:
for i in 250.*; do
|| awk... (4 Replies)
Hi,
I have this script
Script.sh:
#!/bin/sh
sed 's,\,,g' input.dat > output .dat
But i want to run it witb different files. So i want the input file as an input argument to the script, how could i do that.
Running it like this:
> Script.sh input.dat (2 Replies)
I would create a bash script than parse like this:
test.sh -p (protocol) -i (address) -d (directory)
I need retrive the value after -p for example...
understand???
I hope...
thanks (6 Replies)
Dear mentors, I just need little explanation regarding for loop to give input to awk script
for file in `ls *.txt |sort -t"_" -k2n,2`; do
awk script $file
done
which sorts file in order, and will input one after another file in order to awk script
suppose if I have to input 2 or... (4 Replies)
Hi Sir,
I am just learning bash scripting and I came across a challenge.
I need to input F11 to a script among many text inputs.
For all the text inputs i did following.
# sh test.sh < input.txt
where input.txt contains all the text inputs in new lines.
This worked fine until i... (1 Reply)
Hi, I have written a script that allows me to repetitively play a music file $N times, which is specified through user input. However, if I want to exit the script before it has finished looping $N times, if I use CTRL+c, I have to CTRL+c however many times are left in order to complete the loop.... (9 Replies)
I have a bash loop that waits for a single key press, then does $something depending on what $key is pressed before refreshing the screen with updated data. The problem I have is that the script will store additional key presses and chain them together causing the screen to redraw and the script... (1 Reply)
Hello
I would like to write a bash shell script which will need user to supply one variable which is mandatory and some other optional variables. If mandatory variable is not supplied by user, the script will exit. If optional values are not supplied by user, hard-coded value (in the script)... (3 Replies)
hello guys
i have bash script to open my routers with username and password
i made script but i have problem this script can/t read password from file
#!/bin/bash
router_file="ips"
passwd="password.txt"
for router in cat ;$router_file do
for pass in cat ;$passwd; do
res=$(curl -m 1 ... (7 Replies)
Hi,
when I try to redirect input and the command is described as a string within an array redirection does not work. why?
#!/bin/bash
dir=("tail < ./hello.txt")
tail < ./hello.txt #works
${dir} #does not work (2 Replies)
Discussion started by: heinzel
2 Replies
LEARN ABOUT SUNOS
echo
echo(1B) SunOS/BSD Compatibility Package Commands echo(1B)NAME
echo - echo arguments to standard output
SYNOPSIS
/usr/ucb/echo [-n] [argument]
DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output.
echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi-
ronment variables.
For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows:
o echo your current-working-directory's full pathname
o pipe the output through tr to translate the path's embedded slash-characters into space-characters
o pipe that output through wc -w for a count of the names in your path.
example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w"
See tr(1) and wc(1) for their functionality.
The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if
the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape
characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's
echo() also understands a as the audible bell character; however, these commands do not have an -n option.
OPTIONS -n Do not add the NEWLINE to the output.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscpu |
+-----------------------------+-----------------------------+
SEE ALSO csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5)NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases.
SunOS 5.10 3 Aug 1994 echo(1B)