I don't have any idea how these files came about to be, but here's what it looks like with
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 -
^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.
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
findfilter does not have a wildcard, so it cannot work. No idea if it’ll work with a wildcard though.
\rin some circumstances is shown as
^Mor denoted as
CR(these are different representations of the same single-byte character). When reading a script Bash treats sole
\nas line terminator, almost any *nix tool does. If there is
\rjust before, it gets interpreted as any other character. E.g.
touch /path/to/file\rwill create a file with the name that can be represented as
dos2unixor don't use text editors that use
CRLFin the first place.
CRLF. If you happen to transfer your scripts via FTP(S) then compare this answer. Windows-centric text editor is a more probable cause though.