-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash.txt
126 lines (86 loc) · 1.93 KB
/
bash.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
# bash cheetsheet
#
http://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/
http://ss64.com/bash/syntax-keyboard.html
http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/
http://teohm.com/blog/2012/01/04/shortcuts-to-move-faster-in-bash-command-line/
http://lifehacker.com/5743814/become-a-command-line-ninja-with-these-time-saving-shortcuts
#
# bash utilities and libraries
#
https://github.com/gruntwork-io/bash-commons
#
# copy file structure to destination
#
svn status | awk '{printf "%s\n", $2}' | grep -e ".*\.cpp$" -e ".*\.h$" | xargs tar cvf - | (cd ../r48733_bkp ; tar xfp -)
#
# patch
#
# create patch
svn diff TSES/ > STANDALONE.patch
# apply patch (-p0: explicitly tell to strip 0 components from file names)
patch -p0 -i STANDALONE.patch
# undo patch
patch -R -p0 -i STANDALONE.patch
#
# grep
#
grep -r "searchstring" <path>
grep -r --include="*.cpp" --exclude-dir="*_test_*" -e "searchstring"
#
# find
#
find . -name "*.so"
# directory
find . -type d -name arm
#
# zip
#
zip -r myfiles.zip myfiles
#
# tar
#
# backup folder
tar -cvjf V1.4.0.tar.bz2 V1.4.0/
#
# sort
#
# sort by time
ll -t
# last 20 entries, sorted by change time
ll -t | head -n 20
#
# pipe
#
# pipe stderr to stdout
./run.sh 2>&1
# pipe stdout and stderr to file
./run.sh &> run.log
#
# format console output
#
# ansi escape sequences
```
echo -e '\033[0mNORMAL STRING \033[1mBOLD STRING \033[0mNORMAL STRING'
```
```
bold () {
echo -e "\033[1m$@\033[0m"
}
bold_cyan () {
echo -e "\033[0;36m\033[1m$@\033[0m"
}
bold hello world
bold_cyan hello world
```
source:
https://stackoverflow.com/a/42449998/5011904
http://ascii-table.com/ansi-escape-sequences-vt-100.php
https://unix.stackexchange.com/a/158421
# tput utility
bold=$(tput bold)
normal=$(tput sgr0)
echo "this is ${bold}bold${normal} but this isn't"
source:
https://stackoverflow.com/a/2924755/5011904