foo1=$(cat foo2) does not work as expected (by me).
Kernel 2.6.21.5
Hi: Code:
bash-3.1$ cat radios |
I suspect this is because you store it in a variable. So this is translated like this:
Code:
u12=Antena 2: mms://195.245.168.21/antena2 (para mplayer). <enter> Code:
cat radios > u12 |
You have something wrong with the radios file.
When I try to repeat this it works, but not as you would like, I suspect. Code:
[smoker@kids radio]$ cat radios If so you need to edit it and remove the breaks and re-enter them. I created my radios file using vi. Also, try using double quotes : Code:
[smoker@kids radio]$ echo "$ul2" |
what is value of IFS?
Quote:
also try with bash -x to see what is happening along with trying to see if the values were stored in array by printing the size of u12 as Code:
echo ${#u12} |
Yes. Just after posting I suspected the file from where radio came from could have <CR><LF> line terminators. I used vim's 'set ff=unix' command to remove the carriage return chars, and hexdump showed the <CR>s where gone.
After that, I get the same output as you for the command 'echo $u12' and, yes, I would like the <CR> to remain. Thanks a lot. EDIT *** I overlooked the rest of smoker's post. Sorry. |
See my edit about double quotes.
|
+1 to smoker's idea that the problem in in the file, not in the bash commands and that you need to double quote the variable when echoing it. I don't believe $IFS is relevant except when echoing $u12 without quotes. Here's experimenting with IFS:
Code:
c@CW8:/tmp$ IFS=e |
I'm reading it. I double quoted and, same output as you. I beleave the syntax for bash is far more complicated than C's syntax. Let us keep reading.
|
Yes, two posts instead of one. But editing the last one I do not know if makes people take notice as much as a new one.
Well, catkin, and what is this IFS after all? In the meantime, I'll try to figure out its meaming from bash man. EDIT *** In bash, it's a shell variable, whose meaning is *** very well explained (manual). |
IFS is well documented but it is not always intuitively obvious in which situations it is relevant.
|
Try this:
Code:
u12="$(cat radios)" |
Quote:
EDIT: even more precisely (!) the value will be split into words everywhere it contains one or more characters that are in $IFS and reassembled with the words separated by a space: Code:
c@CW8:/tmp$ IFS=' |
All times are GMT -5. The time now is 02:07 PM. |