Last active
August 29, 2015 14:15
-
-
Save tjweir/098e8e45cc81bf506e37 to your computer and use it in GitHub Desktop.
UNIX command syntax I often forget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. Find by filename in the current directory hier | |
| find . | grep filename.ext | |
| #or | |
| find . -name filename.ext | |
| # 2. Specific find, getting rid of those files with .orig suffix | |
| find . -name \*.orig | xargs rm -f '{}' | |
| # 3. making sql command from a .csv | |
| # pairs.csv has: | |
| # XXX,YYY | |
| # AAA,BBB | |
| #!/bin/bash | |
| for i in `cat pairs.csv`; do | |
| ONE_ID=`echo $i | cut -f 1 -d,` | |
| TWO_ID=`echo $i | cut -f 2 -d,` | |
| echo "UPDATE users SET one_id=$ONE_ID WHERE two_id=$TWO_ID;" | |
| done | |
| # 4. nginx rewrite | |
| rewrite ^ http://example.com permanent; | |
| # 5. better dos2unix | |
| tr -d '\r' < in.file > out.file | |
| #6. replace in files | |
| perl -pi -e 's/OLD/NEW/g' *.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment