Hi I have around 300 files in a folder. When I type ls -l I see the following
Mouse.chr10_+_:101862321-101863928.maf
Mouse.chr10_+_:101862322-101863928.maf
Mouse.chr10_+_:101862323-101863928.maf
But when I run my scripts, they couldn't recognise the filename because of hidden backslash like the below.
Mouse.chr10_+_\:101862321-101863928.maf
Mouse.chr10_+_\:101862322-101863928.maf
Mouse.chr10_+_\:101862323-101863928.maf
Is there anyway to remove all these hidden backslashes from multiple file names ?
Does the hidden the \ appear in this command?
ls | cat -vet -
The reason I ask is there is possibly some other unprintable character in the filename right after the \. There is no need to escape a colon that I am aware of.
If the files were brought over from another system with a different locale setting, then this is likely. So before we suggest something that will cause problems we really need to see what is going on.
I see like this
Mouse.chr10_+_:101862321-10186392.maf$
Mouse.chr10_+_:101862321-10186392.maf$
Mouse.chr10_+_:101862323-10186392.maf$
There has to some weird character in there - if
ls | od -c
shows nothing
odd try this:
ls | while read fname
do
prefix="Mouse.chr10_+_"
suffix=$(echo "$fname" | awk -F ':' '{print $2}')
newfile="${prefix}:${suffix}"
mv "$fname" "${newfile}"
done
And. This is very odd if there really is no other character after the \.
sorry but I have combinations of names like this
Mouse.chr1_+_
Mouse.chr2_+_
Mouse.chr3_+_
Mouse.chr4_+_
Mouse.chr5_+_
Mouse.chr6_+_
Mouse.chr7_+_
Mouse.ch8_+_
Mouse.chr9_+_
Mouse.chr10_+_
Mouse.chr11_+_
Mouse.chr12_+_
Mouse.chr13_+_
Mouse.chr14_+_
Mouse.chr15_+_
Mouse.chr16_+_
Mouse.chr17_+_
Mouse.chr18_+_
Mouse.chr19_+_
Mouse.chrX_+_
Mouse.chrY_+_
Mouse.chr1_-_
Mouse.chr2_-_
Mouse.chr3_-_
Mouse.chr4_-_
Mouse.chr5_-_
Mouse.chr6_-_
Mouse.chr7_-_
Mouse.ch8_-_
Mouse.chr9_-_
Mouse.chr10_-_
Mouse.chr11_-_
Mouse.chr12_-_
Mouse.chr13_-_
Mouse.chr14_-_
Mouse.chr15_-_
Mouse.chr16_-_
Mouse.chr17_-_
Mouse.chr18_-_
Mouse.chr19_-_
Mouse.chrX_-_
Mouse.chrY_-_
CarloM
December 13, 2013, 8:08am
6
quincyjones:
But when I run my scripts, they couldn't recognise the filename because of hidden backslash like the below.
Mouse.chr10_+_\:101862321-101863928.maf
Mouse.chr10_+_\:101862322-101863928.maf
Mouse.chr10_+_\:101862323-101863928.maf
What is producing this output? Can you show the relevant part of your script?