echo concat values
I have been playing with this for hours. I have two values I set min and max. When I use echo on them seperately they print the values fine. When I concat the values in echo the first value does not print. When I set the values outside of awk using the terminal interactivly it prints fine. When I tried
Code:
echo -n $max + $min ] CALL TO SCRIPT Code:
$ ./genbnds.sh polprmest.R 100 20 Code:
... |
It works for me. Verify that you are using bash.
Code:
#!/bin/bash |
I am using bash and it does work fine if I set the values specifically like you did. It only happens when they are set using awk.
Here is the file I am using awk on. Not sure if that helps Code:
1,"2007-11-30",24.74 |
Quote:
Anyhow, the following (still) works: Code:
#!/bin/bash |
If the text files has windows end of lines - ascii 13, it will be included in the end of the variable.
Edit, like this: echo -e '57.92\r + 24.74' |
Quote:
Thanks for the help with this whats with the ] in Code:
echo -n $max + $min ] |
Did you try removing the \r characters?
Code:
min=`awk 'BEGIN{FS=","}; min=="" || $3 < min {min=$3} END {print min}' nonhead |tr -d '\r'` |
Well I have 2 questions:
1. Are you able to echo the variables on there own, eg. echo $min? 2. Why not just do it all in awk? |
Quote:
Code:
max=`echo $max | tr -d '\r'` |
Quote:
|
Quote:
|
Just to add onto Guttorm's previous statement, you can indeed use awk to remove the \r if you are constantly dealing with Windows files.
Take a look at the RS component of awk, is default is a newline (\n) but it can be set to multiple values, such as: Code:
RS="[\n\r]+" |
Quote:
Code:
RS="\n\r?|\r\n?" |
All times are GMT -5. The time now is 01:29 AM. |