Hi
well I am facing some problem while trying to concatenate contents of several files, present inside a folder.
My code gives an error:
./test.sh: line 17: [: =: unary operator expected
and in similar lines
Attached is the code:
#!/bin/bash
str1="test_concatenated_RAxML_outputs.txt"
str2="r_test_concatenated_RAxML_outputs.txt"
str3="m_test_concatenated_RAxML_outputs.txt"
str4="n_test_concatenated_RAxML_outputs.txt"
str5="h_test_concatenated_RAxML_outputs.txt"
for line in $(ls -l1 | grep ^d|awk '{print $9}');
do
for lines in $(ls -l1 ./$line | grep ^d|awk '{print $9}');
do
cd ./$line
cd ./$lines
if [ $lines == "final_outputs" ]
then
#textme=`find . -name test_concatenated_RAxML_outputs.txt -printnes/ ../../../texttemp/`
textme=`ls -l|grep -v '^d'|awk '{print $9}'`
if [ $textme = "test_concatenated_RAxML_outputs.txt" ]; then
cat $textme >>../../../texttemp/final_outputs/test_concatenated_RAxML_outputs.txt
elif [ $textme = $str2 ]; then
cat $textme >>../../../texttemp/final_outputs/r_test_concatenated_RAxML_outputs.txt
elif [ $textme = $str3 ];then
cat $textme >>../../../texttemp/final_outputs/m_test_concatenated_RAxML_outputs.txt
elif [ $textme = $str4 ]; then
cat $textme >>../../../texttemp/final_outputs/n_test_concatenated_RAxML_outputs.txt
elif [ $textme = $str5 ]; then
cat $textme >>../../../texttemp/final_outputs/h_test_concatenated_RAxML_outputs.txt
else
cp -r ./ ../../../texttemp/final_outputs
fi
fi
it will be great if somebody can help.
Thanks
Aj