I need to cat
two files with similar names. I am using the following script:
#!/bin/bash
if [[ -f $1 ]]
then
file=$1
file2="${file%R1.fastq}R2.fastq"
echo fetching data from R2 file ...
sleep 3
cat $file $file2 > infile
else
echo "Input_file passed as an argument $1 is NOT found."
exit;
fi
However, I was expecting this to work too:
file=$1
file2=eval echo "$file" | sed -r 's/(.*)R1(.*)/\1R2\2/'
What am I doing wrong in my second script?
The second question would be, why I cannot use cat "${file*}
to concatenate both files?
Thanks in advance for any help!