Skip to content

Instantly share code, notes, and snippets.

@stormbreakers
Forked from jeremenichelli/bash-reference.md
Created January 18, 2016 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stormbreakers/10828b2651f440ca1f63 to your computer and use it in GitHub Desktop.
Save stormbreakers/10828b2651f440ca1f63 to your computer and use it in GitHub Desktop.
Bash reference

rm

Removes a file

rm app.js

cp

Copies a file

cp app.js js/app.js

mkdir

Creates a new folder

mkdir assets

&

Runs to commands simultaneously

lessc main.less main.css & browserify main.js -o bundle.js

&&

Runs the second command only if the first ended up successfully

cp app.js js/app.js && rm app.js.

||

Runs the second command only if the first failed

uglify app.js app.min.js || echo "Error!"

|

This one is one of my favorites, it pipes the output of the first command as the input of the second command, for example after you create a bundled file with browserify you can minify it using uglify.

browserify app.js | uglify app.min.js

<

Inputting the contents (stdin) of a file to a command

>

Redirecting output (stdout) of a command and dumping it to a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment