News for hackers. Stuff that matters.
Re:How to navigate directories faster with Bash (2015) by seesawtron on Thursday April 22, 2021 @04:39AM (#26900322)
Cool one. "Ctrl + R" also does the same thing to search through past commands and then "Tab" to select the command you are looking for.
Re:How to navigate directories faster with Bash (2015) by alex_smart on Thursday April 22, 2021 @05:10AM (#26900516)
May favorite bash "trick" is:

!-1:gs/hello/world

which runs the last command with all instances of hello replaced by world. !-1 can be any so called event designator, for instance !n to refer to any specific line number from history or !string for last command containing a particular string.

Seriously people, read the man page for bash. Your shell has so many cool features.

Re:How to navigate directories faster with Bash (2015) by tikkabhuna on Thursday April 22, 2021 @05:53AM (#26900774)
And if you only have a single instance to replace, you can use ^old^new^

$ echo "hello hello hello world" hello hello hello world $ ^hello^bonjour^ echo "bonjour hello hello world" bonjour hello hello world

Re:How to navigate directories faster with Bash (2015) by alex_smart on Thursday April 22, 2021 @06:16AM (#26900981)
I know that this expansion exists, but never use it in practice.

Why? The last command is more general, you can just drop the g from the command I wrote to only replace the first occurrence. Besides, :[g]s/old/new should already be familiar to anyone who has used vim, so that is almost like having to learn zero new things.

Re:How to navigate directories faster with Bash (2015) by dcassett on Thursday April 22, 2021 @08:19AM (#26901876)
This is great for removing an option from a prior command such as unzip -t ...:

^-t