BASH: How can I get an array with ls-output containing blanks?
Hello!
I like to get an array with every path containing a file ".tag" in the sub-subdirectory: Code:
TAGPATH="*/*/.tag" I've tried every ls option I know, tried to manipulate the output with sed to escape the blank characters, but neither helped. Without blanks it's no problem, but with blanks it seems to be impossible. Can someone help me solving this problem? Thanks in advance! |
If you were to get the paths into an array, you would be able to do this:
Code:
PATHS=("/tmp/what ever/this1" Edit: Or, now that I'm re-reading it, are you looking for how to get the paths into the array in the first place? If so, just use IFS to call out \n\t as field seperators, and ignore spaces, while you are importing it into the array. Code:
IFS=$'\t\n' |
$IFS does the trick!
Thank you very much!!! Greetings from Vienna! Ernst |
It's a lot easier if you don't use ls:
Code:
TAGPATH="*/*/.tag" It is almost always a bad idea to process the output from ls. That output is primarily intended for human consumption. |
Quote:
|
All times are GMT -5. The time now is 09:43 PM. |