forked from xchintan/ubuntu-dev-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtips.sh
executable file
·35 lines (31 loc) · 1.6 KB
/
tips.sh
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
#!/bin/bash
# Only bash has a syntax to declare array. 'sh' does not have
# So if you use !/bin/sh in the first line the script would fail
declare -a tiplist=(
'sudo apt-get --assume-yes install .. to intall packages without prompt'
'apt list --installed #Gets you list of the install packages'
'apt-cache search package-name #Search list of available packages'
"comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u) #Gets list of manually installed packages"
'apt-mark showmanual #List of manual packages'
);
#http://unix.stackexchange.com/questions/37411/multiline-shell-script-comments-how-does-this-work
: << 'be_aware_of_comments'
This is an abuse of the null command ':' and the here-document syntax
to achieve a "multi-line comment". According to the POSIX spec linked
above, if any character in the delimiter word ("end_long_comment" in
this case) above is quoted, the here-document will not be expanded in
any way. This is **critical**, as failing to quote the "end_long_comment"
will result in the problems with unintended expansions described above.
All of this text in this here-doc goes to the standard input of :, which
does nothing with it, hence the effect is like a comment. There is very
little point to doing this besides throwing people off. Just use '#'.
be_aware_of_comments
: <<'comment'
echo ${tiplist[@]} # Gets you all the elements in the array in one go
echo ${#tiplist[@]} #Number of the elements in the array
echo ${#tiplist[0]} #Lenght of first element
comment
for tip in "${tiplist[@]}"
do
echo " $tip"
done