Bash

From Cheatsheet

Jump to: navigation, search

Bash is cool, you can do stuff with it

Notes
#!/bin/bash the first line always
A=`grep whatever somefile`
echo $A
runs a command, assigns it to the variable "A", then prints that variable. Note: you need the backward single quote around the command
tee output_file.txt word counts my_text_file.txt and then outputs the results to output_file.txt
sed -n '/^\s*#/{N;s/^#.*\n//p}' somefile super cool stream editor
-n suppress automatic printing of pattern space

remove spaces in filenames

 for file in *; do mv "$file" `echo $file | sed -e 's/  */_/g' -e 's/_-_/-/g'`; done