Consider the following output commands:
$ du -sm ~/Documents
458 /home/utilisateur/Documents
$ du -sm ~/Documents --exclude='aa bb' --exclude='cc dd'
153 /home/utilisateur/Documents
I want to replace the exception with a single variable like this in order to get the same result.
$ du -sm ~/Documents "$c"
But, if I set a variable with the following, I failed. I tested:
$ c=--exclude='aa bb'\ --exclude='cc dd'
$ du -sm ~/Documents "$c"
458 /home/utilisateur/Documents
$ c="\"--exclude='aa bb' --exclude='cc dd'\""
$ du -sm ~/Documents $c
458 /home/utilisateur/Documents
du: cannot access '"--exclude='\''aa': No such file or directory
du: cannot access 'bb'\''': No such file or directory
du: cannot access 'dd'\''"': No such file or directory
$ c="--exclude='aa bb' --exclude='cc dd'"
$ du -sm ~/Documents "$c"
458 /home/utilisateur/Documents
$ du -sm ~/Documents $c
458 /home/utilisateur/Documents
du: cannot access 'bb'\''': No such file or directory
du: cannot access 'dd'\''': No such file or directory
Please help me fix my mistake. I know this about quotes.
source
share