Ask HN: What are your favorite one-liner shell commands you use?

2 rajkumarsekar 2 7/17/2025, 4:45:21 AM
There are plenty of lists online with fancy or obscure one-liners, but I’m curious about the ones people actually use day to day.

Comments (2)

TheNewAndy · 17m ago
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. There were so many commands that I had no hope of remembering them all, but I figured I could just remember a few useful ones - and ctrl+r was one of them (ctrl+w and alt+b were the other two)

More to the letter of the question, I use "cd -" frequently, "ps -e | grep some_process_i_would_like_the_pid_for", and while I don't use it frequently, I didn't know about "ssh-copy-id" for a long time, and would do it manually with a text editor in the past. Sorry if they are not sufficiently fancy - but for things to get used day to day for me, they will need to be short and sweet.

willprice89 · 10m ago
dd if=/dev/zero bs=1M count=10 | nc -N -l -p 12345

Great simple test for network speed on a box without speedtest-cli or other tools installed.