Score:1

Why can't both Windows and Ubuntu recognize a filename with special characters?

tn flag

I was trying to append to a text file in bash in WSL (using the >> operator). Unfortunately since I'm a beginner instead of appending to a file, a new file was made with the >> 'text' as the filename, and it seems like both Windows (GUI) and Ubuntu (rm command) cannot delete the file while it's in the directory (it's shown even when using the dir command).

  • Windows GUI:

    Directory In windows GUI

  • Windows error code:

    Windows error code

  • Bash:

    root@DESKTOP-IA030GJ:/# cd home
    root@DESKTOP-IA030GJ:/home# dir
    English_Class  Finished_Projects  Keeping.txt  Random_Password_Generator_Project  \\n\\n\ -----Changes\   onion_project  pythonwork
    root@DESKTOP-IA030GJ:/home# ls --quoting-style=shell
     English_Class                      '\n\n -----Changes '
     Finished_Projects                   onion_project
     Keeping.txt                         pythonwork
     Random_Password_Generator_Project
    
muru avatar
us flag
Edit your post to add the output of `ls --quoting-style=shell`, please.
KhodeNima avatar
tn flag
@muru Done , Thanks again for your time sir.
muru avatar
us flag
There, now you know what the filename actually looks like. Try `rm` with that filename.
KhodeNima avatar
tn flag
@muru Problem Solved , Thanks for your time , Have a great day.
Score:6
ru flag

This filename contains special characters because of how you originally (accidentally) piped data around. Because of that we need to know the exact filename and use that in the rm command in quotes.

We know that your file is named exactly \n\n -----Changes . So let's use that. Do not remove the single quotes from this command or it won't work.

rm '\n\n -----Changes '

This should get rid of that file completely, without any subsequent issues.

Note that you could also have removed the file by using *Changes* as a pattern for removal, or add the -i flag with this as well to make it interactive to make sure the files you want to delete are in fact being deleted.

KhodeNima avatar
tn flag
Thanks for your time sir, Problem solved .
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.