## centOS
1. check if software info
```
yum info xxx
```
## ubuntu
1. using gpg to encrypt your file
```
gpg --symmetric xxx.txt # encrypt xxx.txt
gpg --decrypt xxx.txt.gpg # decrypt your file
```
## bash scripts
### amazing webs
1. [IBM Developer](https://www.ibm.com/developerworks/cn/linux/l-cn-hardandsymb-links/index.html)
### bash-snippets
1. rename folders
```
ls |cut -c 6- | xargs -i mv rect-{} {}
```
2. check if a variable is empty
see "https://www.cyberciti.biz/faq/unix-linux-bash-script-check-if-variable-is-empty/"
and "https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash"
```
if [ -z "$var" ]
then
echo "\$var is empty"
else
echo "\$var is NOT empty"
fi
```
```
if [ -z ${var+x} ]; then echo "var is unset"; else echo "var is set to '$var'"; fi
```
### grep, sed and awk
1. grep
```
# find filenames in current folder, not include tar
ls | grep -v tar
```
2. sed
get the name of all mp4 video files from current directory.
```
ls *.mp4 | sed 's/.mp4//g'
```
3. [replace a string for all files.](https://stackoverflow.com/questions/4804405/search-and-replace-in-vim-across-all-the-project-files)
```
find ./ -name "*.xml" | xargs sed -i 's/head/helmet/g' {}
# or https://stackoverflow.com/questions/11392478/how-to-replace-a-string-in-multiple-files-in-linux-command-line
find ./ -type f -exec sed -i 's/string1/string2/g' {} \;
# or do it this way
cd /path/to/your/folder
sed -i 's/foo/bar/g' *
```