Skip to content

Instantly share code, notes, and snippets.

@PeterDing
Last active August 29, 2015 13:57
Show Gist options
  • Save PeterDing/9409350 to your computer and use it in GitHub Desktop.
Save PeterDing/9409350 to your computer and use it in GitHub Desktop.
linux skills

sed with re

sed -r '' file      # -r, --regexp-extended

match newline with grep

grep '^$' file.txt

split file to files

split -l [number] --numeric-suffixes=[from number] --additional-suffix=[suffix] file [prefix]
-l, --lines=NUMBER
-d, --numeric-suffixes[=from number]

python - Ascii

chr(97) # 'a'
ord('a') # 97

shell print '' until Ctrl-C

yes ''
yes {1..9} | head -n 3

generate '1\n2\n3\n...n\n'

echo {n1..n2} | sed -r 's/ /\n/g'

cut -- usage

cut -d ' ' -f n1-n2
-d follows a single char
-f follows points of splited field

search apps, lib or etc

pacsearch
pacsearch - Add color and install information to a pacman -Ss search
Usage:   pacsearch <pattern>
Example: pacsearch ^gnome

dictionary with curl

curl dict://dict.org/d:computer

history of reviewed files

less ~/.local/share/recently-used.xbel

split large file, then merge

split -b 100m file_name
cat file_name* > file_name

DNS for fxcking GFW

116.255.162.155
60.190.217.130

sniffer http or tcp

sudo tcpdump -i wlan0 -s 0 -l -w out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment