Hello everyone, I hope you can help me with this issue. I have to delete a file from the server, but every time I try with "rm" the symbol "<" appears instead of the "$" and I have to quit the terminal to be able to work again. Some times it says that the name of the file is too long to be removed or even just modified. What can I do?
The file name is: 'SRR8837339.bam'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''[A'$'\033''['
That's pretty mangled.
Long shot, since removing won't work, but can you try renaming the file first? (
mv stupidlongname.ext newname.ext
). Otherwise you might need to resort tofind
.moving it ... good call Joe
you can even try moving it to /dev/null which will actually also "delete" it
Yeah good idea. I guess this will come down to whether the filename is too long for bash (since that has limits on numbers of commandline arguments and I guess maybe string lengths - but I don't know) or is running in to a specific limitation of the
rm
tool.The terminal hanging I suspect is just the special characters in the file tricking bash in to thinking there's more to come, but the error saying it can't be moved/modified suggests its
rm
itself that's choking (and I would guessmv
has similar limitation - but that is a total guess).I've run in to having too many arguments before, but never one that was too long.
I've already tried to rename it, it says the file name is too long to be modified
I'm guessing you made this file with a script (probably something in python). You might be able to add a remove command to the same script to remove it, since then you're not dealing with bash and requiring a bunch of escapes.
If none of the solutions here work then one can try to open up a graphical SFTP window (use MobaXterm for PC or FileZilla on macOS) and then simply highlight the strange name and delete it.
Solution below removes all files starting with that SRR* which may not always be wanted.