The Wayback Machine - https://web.archive.org/web/20200604202628/https://github.com/jlevy/the-art-of-command-line/issues/453
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History substitution: !!:gs/x/y/ and !!:s/x/y/ and ^x^y #453

Open
jlevy opened this issue Aug 25, 2016 · 0 comments
Open

History substitution: !!:gs/x/y/ and !!:s/x/y/ and ^x^y #453

jlevy opened this issue Aug 25, 2016 · 0 comments

Comments

@jlevy
Copy link
Owner

@jlevy jlevy commented Aug 25, 2016

These history substitutions could be covered.

Should mention global search/replace first, as that is more commonly what is needed.

The ^x^y is a quick trick but users need to know it only does first substitution, which can make it highly error prone. More info:
http://stackoverflow.com/questions/2280778/unix-commandline-history-substitution-foobar-for-multiple-replacements

Common error — doesn't do what you'd hope:

mv foo.txt foo.bak
^foo^bar

Now you just ran mv bar.txt foo.bak and clobbered your foo.bak backup file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.