I used the following command to create a list of URLs that I want to test:
echo -e localhost:8080/reports/{promos,promo-updates,scandown}/{130,139,142}{,-unburdened,-burdened}{,.pdf,.xls,.xlsx,.csv,.preload}"\n" >> urls.txt
Unfortunately the URLs appended to urls.txt
each had a space before them (except for the first, of course). I understand why that happened, and I realize I could just strip it off by piping throug a sed
expression, but I'd like to know if there's a way to suppress it instead. (It may seem silly and pedantic, but it's no different than the preference so many people feel for not "abusing cats".)
I tried double-quoting to suppress word-splitting, but that suppressed the brace expansion too, so that was a no-go.
I tried changing IFS to an empty string, but it didn't work either:
IFS='' echo -e localhost:8080/reports/{promos,promo-updates,scandown}/{130,139,142}{,-unburdened,-burdened}{,.pdf,.xls,.xlsx,.csv,.preload}"\n" >> urls.txt
Nor did changing it to a newline:
IFS='\n' echo -e localhost:8080/reports/{promos,promo-updates,scandown}/{130,139,142}{,-unburdened,-burdened}{,.pdf,.xls,.xlsx,.csv,.preload}"\n" >> urls.txt
Best Answer
You could store the brace expansion in an array, then output it in the manner of your choosing:
Then
or
The echo example looks weird because:
IFS=$'\n' echo "${urls[*]}"
because the variable gets expanded before the new env variable takes effectAlso, note the subtle difference in the dereferencing array index used:
[@]
in the printf example to expand the array into individual words[*]
in the echo example to expand the array into a single word, with elements separated by the first char of IFS