I have a list of files like this:
wgEncodeCaltechRnaSeqGm12878R1x75dFastqRep1.fastq.trim.tags.sam
wgEncodeCaltechRnaSeqGm12878R1x75dFastqRep2.fastq.trim.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep1.fastq.trim00.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep1.fastq.trim01.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep1.fastq.trim02.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep2.fastq.trim00.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep2.fastq.trim01.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd1Rep2.fastq.trim02.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd2Rep1.fastq.trim00.tags.sam
wgEncodeCshlLongRnaSeqGm12878CellPapFastqRd2Rep1.fastq.trim01.tags.sam
I want to remove the Rd1, Rd2 and .sam stings from their file names. With the following bash script, I can remove the Rd1, Rd2 and .sam strings using two commands....
for i in $(ls)
do
echo "${i/Rd?/}"
echo "${i/.sam/}"
done
But I want to know how to do the two substitutions in one step Do you know how to do it?
Thanks for your time!
for i in *notfor i in $(ls)-- the first form will work properly for files with spaces in the name, the second will split those names.