Excluding existing folders in bash
I have a list of directories in a file:
Code:
/root Code:
/a_dir Code:
cat dirlist | xargs -I {} [ -d {} ] |
I don't understand the question. Why don't you simply delete the unwanted entries using sed?
Code:
$ echo "/root Best regards, HMW |
The filter should check if that directory exists. If it does not exist, only then its name should be printed, else not. It could be something like:
Code:
cat dirlist | awk 'if( [ ! -d $1 ] ) print ($1)' |
I think you need use a loop:
Code:
for dir in $(cat dirlist); do |
Thanks. I also managed using awk as follows:
Code:
cat dirlist | awk ' { if ( system(" [ -d " $1 " ] ") ) print $1 } ' |
All times are GMT -5. The time now is 06:32 AM. |