I am using Ubuntu on a Windows 10 machine. I am trying to rename 5 files (file1.txt, file2.txt, file3.txt, file4.txt, file5.txt) so that each file is replaced by Sample#_VoucherID.fastq.gz.
To do this, I haver a .csv file that has a format of
oldfile,newfile and I am using
sed as follows”
sed 's/^/mv -vi /;s/,/ /;s/$//' < File-Rename.csv | bash -e
Whenever I run this, I instead of getting:
Sample#_VoucherID.fastq.gz for each file, I get
'Sample#_VoucherID.fastq.gz'$'r' instead. Why is this happening? If I use
mv just in the Ubuntu terminal to rename files, I get the files renamed as I want, without the
before and after the file name. If I don’t use the
| bash -e in the file and I remove the quotes, it prints:
mv -vi file1.txt Sample1_VoucherID.fastq.gz mv -vi file2.txt Sample2_VoucherID.fastq.gz mv -vi file3.txt Sample3_VoucherID.fastq.gz mv -vi file4.txt Sample4_VoucherID.fastq.gz mv -vi file5.txt Sample5_VoucherID.fastq.gz
however, it does not actually run the
mv command. How can I rename my files without getting those extra characters?