29

I have a filename @! in my home folder. When I open it, it has the same content that my other bash file myscript.sh has.

I have not assign execute permission to original bash file. When I have checked properties, the only difference between two file is size. Original file size is 1.1 KB and @! file size is 714 bytes. How is it automatically created?

d a i s y
  • 5,561

1 Answers1

97

If you use Vim, this could be because you typed :w@! instead of :wq!. On the US layout, @ is on 2, directly above QW, and right next to ! on 1. Easy to mistype.

You can verify this by running Vim again, and examining the command history by either scrolling up using the up arrow key in command mode, or typing q: in normal mode.

muru
  • 207,970
  • 20
    Well, I do have a bunch of files named cat lying here and there because I typed :'<,'>w! cat instead of :'<,'>w !cat. – muru May 24 '18 at 11:17
  • 2
    I've again checked the content of both file again. Size difference is because the original file content is bit modified after mistakenly created @! file. So indeed this should be accepted answer. – d a i s y May 25 '18 at 03:20
  • 1
    @muru you should erase your identity and go work as a secret detective. Wow... – Raja Anbazhagan May 26 '18 at 05:38
  • As a Vim noob, why would you combine ! with w? Try to save a maybe-read-only file but quit anyways? – Nick T May 26 '18 at 14:53
  • 1
    @NickT : Maybe because people are often just taught that "q!" means quit without asking questions, and inserting a w before that will write. (Technically you should ask such a question as a separate question, but I figured that might be downvoted/closed as a not-researched-well-enough question.) – TOOGAM May 26 '18 at 20:14
  • @NickT If you own a file with mode 05??, it will be "read only", even to you. But vim knows that you own it and you can force it with :w!. – Dessa Simpson May 27 '18 at 05:03
  • 2
    and here is my command line history : :wq, :wq@!, :.!:q!,:w@!, :wq!, :q! – d a i s y May 28 '18 at 04:57