I rarely use the exact samme command multiple times. But here are some bash pipe segments I enjoy.
using pv (pipeviewer) instead of cat to get a progress bar when grepping huge files.
Using httpie instead of curl so I can remember the flags.
The power of find -exec to run commands on a lot of specific files. The nice part is you can run it without exec first to see if you have the right set of files.
If you do a loop you can echo -e “$somevar\r” and then each write will overwrite the previous line so you screen doesn’t fill up but you do get a feel for the progress (to make it nice you need to pad with spaces, google for echo carriage return to learn more)
That’s an impressive collection. Definitely not basic! Love how practical these are for real-world ops work, especially the MySQL .ibd optimizer loop and swap memory check.
Defined this in whatever init script the shell uses so that I get a long listing of files (first alias below) and long listing of files sorted from oldest to newest (second alias below):
alias 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.
> GNU Screen window with CTRL-A + Shift-H to log all output to logfile
tmux users can use it's `capture-pane` command, either before or after the fact if history is set big enough. There are several helpful flags worth researching.
e.g. `tmux capture-pane -pS - > ~/tmux.log` in a shell to save the history of that pane,
or just `prefix+: capture-pane ...` from within tmux
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.
I also same here. Has since I discovered Ctrl+R, and equipped it with fzf (https://github.com/junegunn/fzf), every terminal command is in my hand, I can fuzzy search and not need to remember the exact command. This really saved me a lot of times.
`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 :)
No need to be fancy. These are super practical! ctrl+r is a lifesaver once it clicks, and cd - is such a small thing that makes moving around so much smoother.
I have a super neat one but it's on my work machine. Not strictly a one-liner but definitely a CLI QoL improvement. It allows me to type a partial command, for e.g. up to where a file path might be, hit a hotkey to invoke (e.g.) fzf, and finally have fzf's output inserted where my cursor was in the command. Uses some vars that readline exposes. I haven't taken it beyond inserting paths yet, but you could imagine you could do a lot with inserting arbitrary output into a command you are midway through typing. I'll reply to this when I have it on hand.
samgutentag|7 months ago
andrei_says_|7 months ago
rajkumarsekar|7 months ago
optbuild|7 months ago
[deleted]
jauco|7 months ago
using pv (pipeviewer) instead of cat to get a progress bar when grepping huge files.
Using httpie instead of curl so I can remember the flags.
The power of find -exec to run commands on a lot of specific files. The nice part is you can run it without exec first to see if you have the right set of files.
If you do a loop you can echo -e “$somevar\r” and then each write will overwrite the previous line so you screen doesn’t fill up but you do get a feel for the progress (to make it nice you need to pad with spaces, google for echo carriage return to learn more)
gaws|7 months ago
How does this work?
rajkumarsekar|7 months ago
scrapheap|7 months ago
geocrasher|7 months ago
rajkumarsekar|7 months ago
bravesoul2|7 months ago
AnonHP|7 months ago
alias 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.
rramadass|7 months ago
<make/build script> 2>&1 | tee build.log | grep <whatever>
2) Do everything within GNU Screen window with CTRL-A + Shift-H to log all output to logfile i.e. "screenlog.<window num>".
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.
lozf|7 months ago
tmux users can use it's `capture-pane` command, either before or after the fact if history is set big enough. There are several helpful flags worth researching.
e.g. `tmux capture-pane -pS - > ~/tmux.log` in a shell to save the history of that pane, or just `prefix+: capture-pane ...` from within tmux
TheNewAndy|7 months ago
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.
vinhnx|7 months ago
scrapheap|7 months ago
rajkumarsekar|7 months ago
000ooo000|7 months ago
sshine|7 months ago
Install Tailscale on your machines, and your work machine is always just one ssh command away.
jjgreen|7 months ago
sshine|7 months ago
PeterWhittaker|7 months ago
tmaly|7 months ago
For complex one liners, I keep them in a simple txt file with a brief description so I can find them later when I need to use them again.
rajkumarsekar|7 months ago
UI_at_80x24|7 months ago
```alias hstat="curl -Lo /dev/null --silent --head --write-out '%{http_code}\n'" $1 #HTTP status code```
example:
```$ hstat google.com 200```
scrapheap|7 months ago
willprice89|7 months ago
Great simple test for network speed on a box without speedtest-cli or other tools installed.
xiconfjs|7 months ago
AnonHP|7 months ago
yjftsjthsd-h|7 months ago
peter-m80|7 months ago
bravesoul2|7 months ago
docker ps
docker kill
git switch
git commit
git push
rajkumarsekar|7 months ago
noperator|7 months ago
https://github.com/noperator/sol