From 8e9cfc0eb1829ae5799bf25bb7e68906e07af6d8 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Sat, 10 Aug 2013 16:32:49 -0400 Subject: [PATCH] Still hacking in cheat sheets. Wrote a trivial python installer. --- cheat | 44 +++++++++++++++++++++++++++++++++----------- install | 10 ++++++++++ 2 files changed, 43 insertions(+), 11 deletions(-) create mode 100755 install diff --git a/cheat b/cheat index 21dc14d..5c25d6e 100755 --- a/cheat +++ b/cheat @@ -10,7 +10,6 @@ cheatsheets = { # @todo: # - adb # - at -# - cut / split? # - dd # - df # - du @@ -23,7 +22,6 @@ cheatsheets = { # - mongoimport # - nc # - rsync -# - sed # - shred # - useradd / adduser # - xargs @@ -134,6 +132,30 @@ notify-send -i 'icon-file/name' -a 'application_name' 'summary' 'body of message The -i and -a flags can be omitted if unneeded. ''', +########## sed ################################################################ +'sed' : ''' +To replace all occurrences of "day" with "night" and write to stdout: +sed s/day/night file.txt + +To replace all occurrences of "day" with "night" within file.txt: +sed s/day/night file.txt > file.txt + +To replace all occurrences of "day" with "night" on stdin: +echo 'It is daytime' | sed s/day/night/ +''', + +########## split ############################################################# +'split' : ''' +To split a large text file into smaller files of 1000 lines each: +split file.txt -l 1000 + +To split a large binary file into smaller files of 10M each: +split file.txt -b 10M + +To consolidate split files into a single file: +cat x* > file.txt +''', + ########## sockstat ########################################################## 'sockstat' : ''' To view which users/processes are listening to which ports: @@ -155,15 +177,6 @@ For more information, see: http://unix.stackexchange.com/q/12755/44856 ''', -########## redirection ######################################################## -'stdout' : ''' -To redirect stderr to stdout: -some-command 2>&1 - -To redirect stderr to a file -some-command 2> errors.txt -''', - ########## ssh-copy-id ######################################################## 'ssh-copy-id' : ''' To copy a key to a remote host: @@ -188,6 +201,15 @@ To copy a key to a remote host on a non-standard port: ssh-copy-id username@host -p 2222 ''', +########## stdout ############################################################# +'stdout' : ''' +To redirect stderr to stdout: +some-command 2>&1 + +To redirect stderr to a file +some-command 2> errors.txt +''', + ########## tar ############################################################### 'tar' : ''' To extract an uncompressed archive: diff --git a/install b/install new file mode 100755 index 0000000..2f4b01d --- /dev/null +++ b/install @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import shutil +import sys + +try: + shutil.copy('./cheat', '/usr/local/bin/') + # shutil.move('./.cheat', '~') +except IOError as e: + print >> sys.stderr, "This installer must be run as root." + sys.exit(1)