I don't have any idea how these files came about to be, but here's what it looks like with ls -lh
:
total 8.1G
-rw-r--r-- 1 root root 1.6G Apr 13 2022 test_some_data_S6_R2.fastq.gz?
-rw-r--r-- 1 root root 1.5G Apr 13 2022 test_some_data_S6_R1.fastq.gz
When I use ls to get the file name to auto-complete, it looks like this -
ls /path/to/file/test_some_data_S6_R2.fastq.gz^M
^M
is supposed to be carrier return in DOS, so my best guess, someone might have copied the name from a Windows system and used that for naming the file. There are plenty of methods to replace ^M
in the contents of the file, but in my case I want to find files with ^M
in its name.
I tried find /path/with/files/ -iname "^M"
, but no luck. I tried to escape with \
, but still no dice. I'm SSHing into a RHEL machine using MobaXTerm, so I tried Windows shortcut CTRL + Q, CTRL + M, but it hides the current working window, and doesn't insert ^M
.
find
filter does not have a wildcard, so it cannot work. No idea if it’ll work with a wildcard though.\r\n
akaCRLF
This\r
in some circumstances is shown as^M
or denoted asCR
(these are different representations of the same single-byte character). When reading a script Bash treats sole\n
as line terminator, almost any *nix tool does. If there is\r
just before, it gets interpreted as any other character. E.g.touch /path/to/file\r
will create a file with the name that can be represented asfile\r
orfile^M
. (contn'd)dos2unix
or don't use text editors that useCRLF
in the first place.LF
toCRLF
. If you happen to transfer your scripts via FTP(S) then compare this answer. Windows-centric text editor is a more probable cause though.