0
for file in /path/path/???????????_aa.fasta.aln.1; do name=$($file|sed 's/.1//g'), echo mv ${file} $sup  ; done

The idea of this code is to change the ???????????_aa.fasta.aln.1 file name into ???????????_aa.fasta.aln

So I had the idea to change the $file value by deleting the .1 and then storing it into the variable name, then I just echo the ancient name $file and the new name name. Then I paste all the code generated.

But it does not work.

Does someone have an idea?

Biffen
  • 6,249
  • 6
  • 28
  • 36
bewolf
  • 165
  • 9
  • 1
    `$file|sed 's/.1//g'` will *execute* the contents of `$file`. You probably meant something like `printf "$file"|sed 's/.1//g'`. (And then `mv "$file" "$name"`, not `… $sup`.) – Biffen Feb 01 '19 at 09:13
  • …but then again you don’t need `sed` (and note that the pattern you use with `sed` matches more than just `.1` at the end); simple parameter expansion would suffice, e.g: `name="${file%.1}"` (Or even `mv "$file" "${file%.1}"`.) – Biffen Feb 01 '19 at 09:16
  • But my files already have .1 at the end, the aim is to remove it. – bewolf Feb 01 '19 at 09:20
  • Yes. That’s what all of my examples above do. – Biffen Feb 01 '19 at 09:20
  • ok but how do I store the "$file"|sed 's/.1//g' part without .1 into the name variable? – bewolf Feb 01 '19 at 09:22
  • Like you do with `name=$(…)`. But that’s not the issue with your code. – Biffen Feb 01 '19 at 09:23
  • I got it ! Thank you for your help. – bewolf Feb 01 '19 at 09:26

0 Answers0