Issue
I have a file called && !!
How do I delete this file?
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
&& !!
rm -- "&& !!"
Result:
rm: cannot remove '&& git st': No such file or directory
As you've might guessed, git st
is my way of git status
.
How did I get here?
Open Vim
:e && !!
:wq
Solution
Your rm -- "&& !!"
attempt failed because history expansion replaced !!
by the previously executed command. You can avoid this by quoting your file name in single quotes since you don't need the content to be expanded:
rm -- '&& !!'
History expansion has tripped me up more often than I liked and I never found a use for the feature, so I chose to disable it by adding set +H
to my .bashrc
file.
Answered By - Aaron Answer Checked By - Willingham (WPSolving Volunteer)