Last active
November 30, 2016 18:25
-
-
Save seanrankin/e6542c997419e22ad593 to your computer and use it in GitHub Desktop.
A collection of examples of shell scripts I've found handy
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
# Securly copy from a remote to local: | |
scp -r [email protected]:/path/to/folder ~/path/to/folder | |
# Pipe out commands to the at command | |
echo "Print this out..." | at 7am | |
# Sleep then do something | |
sleep 10 && echo 'Ten seconds have passed.' | |
# Curl the contents of a file | |
$ for i in `cat urls.txt` ; do curl -O $i ; done | |
# Curl a file and save it locally | |
$ curl -o test.txt http://textfiles.com/adventure/221baker.tx | |
# Rename using a regular expression, remove the echo after testing | |
for f in *.mp4; do echo mv "$f" "${f#*' - '}"; done | |
## GREP | |
# Find a word | |
grep "liver" words.txt | |
# Two characters and then the string | |
grep "..ver" words.txt | |
# Save the results of search to a file | |
grep "liver" words.txt > results.txt | |
# Find in all files | |
sudo find / -name "com.apple.mail.plist" | |
# Find in your home | |
sudo find ~/ -name "com.apple.mail.plist" | |
# Find a type of file | |
find ~/ -iname "*.jpg" | |
# ... and output to a file | |
$ find ~/ -iname "*.jpg" > liver.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment