/
snippets.txt
56 lines (37 loc) · 1.84 KB
/
snippets.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# display the lines 159 thru 170 of filename.txt
$ awk 'NR >= 159 && NR <= 170 ' filename.txt
# Same thing in SED
$ sed -n '159,170p' filename.txt
# copy really-long-filename.txt to really-long-filename.txt.bak
$ cp really-long-filename.txt{,.bak}
# Write one fish two fish red fish blue fish
$ echo {one,two,red,blue}" fish"
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
$ sed '/^$/d;G'
# In UNIX environment, Remove every ^M from text files
sed 's/^M$//g'
# Remove all trailing spaces from end of lines
sed 's/[ \t]*$//'
# print only lines of 81 characters or longer
awk 'length > 80'
# search thru files and skip the .svn directories
find . -not \( -name .svn -prune \)
# Get a blueprint of PHP code - your function and classes with methods
# if 'ack' is not installed, use 'brew install ack'
# replace DIRECTORY with a real directory name
ack --recurse --type=php --with-filename '^\s*(class|(public )?(static )?function)' DIRECTORY
# Like the previous, but also finds required or included files. You'll want to write the results to a file
# due to high number of results
ack --recurse --type=php --with-filename '^\s*((require|include)(_once)?|class|(public )?(static )?function)' DIRECTORY
#
# Checking source code for quality
#
# Do lines begin with spaces?
ack --recurse --type=php --with-filename '^[ ]+(?!\*)' DIRNAME
# Do lines begin with tabs?
ack --recurse --type=php --with-filename '^\t+' DIRNAME
# check that developers included the phpdoc before their classes and functions
ack --recurse --type=php --with-filename -B 10 '^\s*(class|(public )?(static )?function)' DIRECTORY
# alt check that developers included the phpdoc before their classes and functions
ack --recurse --type=php --with-filename '(^\s*class|function [\w\d_]+\()' DIRECTORY