4

I want to do this

while read line
do
    echo $line;
    notify-send $line;
done < "0.txt"

where 0.txt is some file with 10 rows

But the problem is

notify-send $line;

causes Invalid number of options, and

notify-send "aasdasdsd" 

works just fine

Charles
  • 50,943
  • 13
  • 104
  • 142
Lukap
  • 31,523
  • 64
  • 157
  • 244

1 Answers1

10

bash do Shell Parameter Expansion before Word Splitting.

notify-send "$line"
kev
  • 155,172
  • 47
  • 273
  • 272
  • it works great, if is not hard for you can you please give me brief explain why is like this ?, thanks – Lukap Jan 13 '12 at 13:22
  • 1
    [helpful link](http://www.gnu.org/software/bash/manual/bash.html#Shell-Expansions) – kev Jan 13 '12 at 13:27
  • @Lukap: It's part of the design of the language. Some would say unfortunately, since it encourages creating filenames and strings with only `[a-zA-Z0-9_-]`, while making some few operations (like `for file in $paths` easier (if you don't have special file names) since you don't have to tokenize the string. Bash didn't use to have support for arrays, which fix most of the looping issues. – l0b0 Jan 13 '12 at 13:55