Skip to content

Instantly share code, notes, and snippets.

@avesus
Last active October 28, 2023 23:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avesus/394fea04b34471fdf23d to your computer and use it in GitHub Desktop.
Save avesus/394fea04b34471fdf23d to your computer and use it in GitHub Desktop.
Unix style
program > file # write program stdout to file
program1 | program2 # send stdout of program1 to stdin of program2
program < file # write file to program stdin
program1 && program2 # exec program2 only if program1 returns 0
program1; program2 # exec program2 ever if program1 failed
cmd1; cmd2; cmd3 & - will only execute cmd3 in the background
cmd1 && cmd2 && cmd3 & - will execute the entire chain in the background IF there are no errors.
To cater for unconditional execution, using parenthesis solves this :
(cmd1; cmd2; cmd3) & - will execute the chain of commands in the background, even if any step fails.
\ - multiline command
program1 || program2 - run program2 if program1 failed
program1 < srcfile | program2 | program3 > dstfile - pipeline with srcfile on input and dstfile on output
mkfifo fifo_file_path - creates a pipe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment