You can exclude a folder while performing given operations.

You can exclude a folder when performing file operations i.e. copy, move,  and chmod, chown etc. in Linix
Please run the given commands:

# shopt -s extglob and now you can use !(<pattern>) to exclude the given pattern.
For an example,
chown 0755 -R !(Folder_name)
chown username: -R !(Folder_name)

 

Advertisements

Grep (E) Syntex

Grep

-E, –extended-regexp
Interpret PATTERN as an extended regular expression
You want to search using a fancy expression. For example parenthesis () can be used to indicate groups with | used as an OR operator.
You could run this search using -E:

grep -E ‘^no(fork|group)’ /etc/group
…to return lines that start with either “nofork” or “nogroup”.
Without the -E switch you would have to escape the special characters involved because with normal pattern matching they would just
search for that exact pattern;

grep ‘^no\(fork\|group\)’ /etc/group

You have a file with a list of say ten Unix usernames in plain text.
You want to search the group file on your machine to see if any of the ten users listed are in any special groups:

grep -F -f user_list.txt /etc/group

 

Cheers!!