DEV Community


Discussion on: What are your UNIX pipeline commands that saved you from lot of coding/time?

jorinvo profile image
jorin • Edited

I think process substitution is incredible helpful. Took me a few years to find out about it.
A super powerful command is xargs. Also make sure to have a look at the -I and -p flags, both really powerful.
I just used these two features as part of an article I wrote,
Automate Your Mac Setup and Keep It Up to Date
Compare the output of two commands, get the result list and pass in one line to another command:

comm -13 <(sort brew.txt) <(brew leaves | sort) | xargs brew rm

And some aliases I like:

# Start a webserver, also accepts a port as optional argument
alias server='python3 -m http.server'

# Copy to clipboard on Mac or Linux
alias copy="$(which pbcopy &> /dev/null && echo pbcopy || echo 'xclip -sel clip')"

# Pipe my public key to my clipboard.
alias pubkey="more ~/.ssh/ | copy && echo '=> Public key copied to pasteboard.'"

If you are curious which commands you use a lot, you can find out like this:
What Are Your Most Used Shell Commands?