From 66166e3dd440110ec1077edf816a2683f7670ef3 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Fri, 9 Aug 2013 23:17:22 -0400 Subject: [PATCH] Still writing cheat sheets. Also made trivial changes to the README. --- README.md | 3 ++- cheat | 46 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e1e8df2..2c6194b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ Cheat ===== - overview -- obligatory xkcd +- obligatory xkcd (http://xkcd.com/1168/)(Embed: http://imgs.xkcd.com/comics/tar.png) - examples - subcommands +- anything, really - help diff --git a/cheat b/cheat index 217320b..4bb2325 100755 --- a/cheat +++ b/cheat @@ -7,7 +7,18 @@ keyphrase = ' '.join(sys.argv[1:]) # create a dictionary of cheatsheets cheatsheets = { -########## convert ########################################################## +########## bash ############################################################### +'bash' : ''' +To implement a for loop: +for file in `ls .`; + do echo 'file'; + echo 'found'; +done + +@todo: if (esp. file/directory) +''', + +########## convert ########################################################### 'convert' : ''' To resize an image to a fixed width and proportional height: convert original-image.jpg -resize 100x converted-image.jpg @@ -22,7 +33,8 @@ To resize an image and simultaneously change its file type: convert original-image.jpg -resize 100x converted-image.png To resize all of the images within a directory: -for file in original/image/path/; +To implement a for loop: +for file in `ls original/image/path/`; do new_path=${file%.*}; new_file=`basename $new_path`; convert $file -resize 150 conerted/image/path/$new_file.png; @@ -31,14 +43,31 @@ done ########## dhclient ########################################################## 'dhclient' : ''' -@todo +To release the current IP address: +sudo dhclient -r + +To obtain a new IP address: +sudo dhclient + +Running the above in sequence is a common way of refreshing an IP. ''', ########## find ############################################################## 'find' : ''' -executable perms -file not directory -directory not file +To find files by extension (ex: .jpg): +find . -iname "*.jpg" + +To find directories: +find . -type d + +To find files: +find . -type f + +To find files by octal permission: +find . -type f -perm 777 + +To find files with setuid bit set: +find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l ''', ########## git ############################################################### @@ -51,11 +80,6 @@ To enable color: git config --global color.ui true ''', -########## ifconfig ########################################################## -'ifconfig' : ''' -@todo -''', - ########## ln ################################################################ 'ln' : ''' To create a symlink: