Sorry, this seems to be a pretty straightforward question but I cannot find the good syntax anywhere I've been looking for...
I am in a directory with some files : a.fa and b.fa
Here is my script:
files=*
for f in $files
do
newname=$(echo $f|awk -F"/" '{print $NF;}'|cut -d'.' -f1);
less $f > less_$newname.txt
filename_$newname="less_$newname.txt"
done
With the following error:
filename_a=less_a.txt: command not found
filename_b=less_b.txt: command not found
What I would like in the end is 4 files in my directory:
a.fa
b.fa
less_a.txt
less_b.txt
And two new variables named filename_a and filename_b
Any idea on how I could do? Thanks!
declare "filename_$newname=less_$newname.txt", but not a great idea. You don't know what variable names are actually defined.