I am doing backup using
for a in /home/* do //do backup done
I want to exclude some folders in /home . but for loop takes all folders i there.
is there any way so that i can specify exclude list at top which can be used in loop
You need some sort of evaluation in order to check what to exclude from the list of folders you get in the "for"; just using bash this could be (you can use whatever you feel comfortable to evaluate what to exclude (ie sed, grep, awk,...)):
However I would have use some other tools for backup such rsync which can exclude by itself, for example:
Since the bash regex is a bit tricky and difficult to implement in some circumstances I've replaced it with a more robust grep statement:
This grep statement will work in a home dir with names such as (where some dirs share common part names and include spaces within):