Not really a shell one liner, but ctrl+r (a readline command to do an incremental search backwards through history) is something that has been present on every shell I've used for decades without realising it, One day I decided to take the time to read all the magic readline commands because I wanted a way to quickly edit the N-th argument of a command with lots of arguments, and there were way too many of them. Ther…
Ask HN: What are your favorite one-liner shell commands you use?
11–20 of 44 posts
Re: Ask HN: What are your favorite one-liner shell commands you use?
#12Re: Ask HN: What are your favorite one-liner shell commands you use?
#13Not really a shell one liner, but ctrl+r (a readline command to do an incremental search backwards through history) is something that has been present on every shell I've used for decades without realising it, One day I decided to take the time to read all the magic readline commands because I wanted a way to quickly edit the N-th argument of a command with lots of arguments, and there were way too many of them. Ther…
`cd -` is great for when you just want to nip out of your current directory for a second and then come straight back - especially as I'm pretty sure that most of us never think about pushd/popd until after we've moved to the other directory with cd :)
Re: Ask HN: What are your favorite one-liner shell commands you use?
#14Re: Ask HN: What are your favorite one-liner shell commands you use?
#15Earlier quoted context omitted.
`cd -` is great for when you just want to nip out of your current directory for a second and then come straight back - especially as I'm pretty sure that most of us never think about pushd/popd until after we've moved to the other directory with cd :)
Semi-related: if I want to do a little side quest, maybe pop over to another repo or git worktree for a quick look, I'll drop into a subshell just by running bash before cd-ing. Then I just exit that shell (alias q=exit) when I want to return back to the original dir and context.
Re: Ask HN: What are your favorite one-liner shell commands you use?
#16:(){ :|:& };:
Re: Ask HN: What are your favorite one-liner shell commands you use?
#17alias ll=“ls -l”
alias lln=“ls -lrt”
Apart from this, I have a few aliases defined to get the size of specific folders and their subfolders (using ‘du -h’ for human readable sizes). The aliases are named like “duh”, “dut” and so on.
Re: Ask HN: What are your favorite one-liner shell commands you use?
#18 git grep foo | cut -d: -f1 | uniqRe: Ask HN: What are your favorite one-liner shell commands you use?
#192>&1 | tee build.log | grep
2) Do everything within GNU Screen window with CTRL-A + Shift-H to log all output to logfile i.e. "screenlog.".
Both lifesavers when working with multiple systems and codebases.
3) Always use "set -o vi" with bash so that i can use vi/vim keybindings across everything.
Re: Ask HN: What are your favorite one-liner shell commands you use?
#20I have had the alias `huh` for years, which is just `pwd; whoami` just to confirm I am where I think I am, and I am who I think I am