Linux Notes¶
The normal settings for /tmp are 1777, which ls shows as drwxrwxrwt. That is: wide open, except that only the owner of a file can remove it (that’s what this extra t bit means for a directory).
Nice commands¶
find duplicate files, generate rm command to remove old same size file to make it remove duplicates, remove echo from xargs.
1 |
|
shell programing tips¶
enable xtrace for shell script
- The
set -x
option instructs bash to print commands and their arguments as they are executed. - The
set -x
option instructs bash to print shell input lines as they are read.
- The
set -e
option instructs bash to immediately exit if any command has a non-zero exit status. - The
set -u
option instructs bash to immediately exit if a reference to any variable you haven’t previously defined - with the exceptions of $* and $@. - The
set -o
pipefail option instructs bash to prevents errors in a pipeline from being masked. - Setting IFS to $’\n\t’ means that word splitting will happen only on newlines and tab characters.
1 2 3 4 5 6 7 |
|
awk example¶
split and print
1 |
|
expect example¶
handle first time ssh login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
coredump file check simple example¶
to check where coredump file will be generate
1 |
|
1 2 3 4 |
|
grep usage¶
To search the string in a single file,
grep file1.txt -e ‘techieshouts’
To search the full word and not the substring,
grep -w file1.txt -e ‘techieshouts’
To search the full word by ignoring case sensitiveness,
grep -wi file1.txt -e ‘techieshouts’
To search all the files recursively in the directory for the same word,
grep -wir /directory -e ‘techieshouts’
To search and get the line number of the word in all the files
grep -wirn /directory -e ‘techieshouts’
To search and get only the file names that contain the word
grep -wirl /directory -e ‘techieshouts’