0

I had a really bad idea: Curious about what could happen, I wanted to try to use various non-alphanumerical characters as file names. Think may have been a bad idea. I created the a file in the terminal, using nano:

nano \.sh

I just wrote echo hello in it, and saved it. Then, I made it executable:

chmod +x \.sh

surprisingly, it printed hello when I wrote ./\.sh

Now, I began to get cold feet about this action. Have I broken something? The file does not show up in any file explorer or in ls, except for in search, where it shows up with an icon that looks like a directory with a wire, without any options. (like "open").

What may have been broken by this foolish action, and if so how can I fix the possible damage?

  • I don't think you broke anything. Can you see it with ls -a? Run rm '\.sh' to delete your file. – Gasp0de Mar 30 '16 at 13:48
  • 1
    You probably actually created a file called .sh (the \ would just - harmlessly - escape the .) - no more special than any other "dotfile" – steeldriver Mar 30 '16 at 14:08

1 Answers1

1

I don't believe you have broken anything. Who cares if the files is not displayed. You have found a good way to hide a file. :)

Otherwise hidden file names are the ones with the dot at the beginning (for instance .bashrc).

You can just delete the file with rm ./\\.sh and there will be no trace of your little experiment.

nobody
  • 4,420
  • rm ./\.sh does not work, (I just used ./ to run it), but rm .sh worked fine. Good to now I have not broken anything :) – SE - stop firing the good guys Mar 30 '16 at 13:53
  • Oohh. I see now! You havent made a .sh file. You made a .sh file. \ is an escape character in bash. Using \ means that the next character is to be taken literally. For instance if you have a space in your filename you can remove is with rm "filename with spaces" or rm filename\ with\ spaces. The first example uses "" to make rm aware thatr spaces do not separate multiple filenames or use \ to use space literally. You could have deleted it with rm .sh too. – nobody Mar 30 '16 at 13:58