linux
Bash : Compound condition using && (AND) and || (OR) operators
&& or ||:-
if [ $VAR1 -eq 1 ] && [ "$VAR2" == "true" ] then # do something fi if [ "$VAR1" == "String 1" ] || [ "$VAR2" == "String 2" ] then # do something fi
Reference: http://www.museum.state.il.us/ismdepts/library/linuxguides/abs-guide/ops.html#ANDOR
- Add new comment
- 121 reads
Bash : Compare Strings With Spaces
To compare two strings that contain spaces in bash, enclose them with a double quote (e.g. "$VAR" ). Example below:-
if [ "$VAR" == "this is a string with spaces" ] then # do something fi
Reference: http://hacktux.com/bash/string
- Add new comment
- 170 reads
Exclude files/directories when using linux tar command
To exclude files/folders when archiving using tar in linux, use the following command:-
tar -czvf filename.tar.gz --exclude 'path1/*' --exclude 'path2/*' --exclude 'path3/*' folder_or_files_to_be_archived
References:-
http://www.wallpaperama.com/forums/how-to-exclude-a-directory-in-a-tar-l...
http://www.cyberciti.biz/faq/exclude-certain-files-when-creating-a-tarba...
http://www.linuxtopia.org/online_books/linux_tool_guides/tar_user_guide/...
- Add new comment
- 509 reads
Recent comments
14 weeks 5 days ago
1 year 4 days ago
1 year 4 weeks ago