echo is not working as expected

for i in `cat /export/home/afahmed/Arrvial_time.txt`
do
       echo $i
      echo $i |  awk '$3 < $D { print $4 }' >> dynamic_DF.txt;

done
 

When i echo, its echo as

Nov
15
02:24
/export/home/pp_adm/inbound//wwallet_20111115.txt where i expect it to be Nov 15 02:24 /export/home/pp_adm/inbound//wwallet_20111115.txt

Could anyone say the reason for it?

for works on words, not on lines.

And it's also a useless use of cat, and a useless use of backticks.

Preferable is to use a construct like:

while read LINE; do
  ...
done < file

Hi scott,

Still i face the same problem after relpacing 'for' with 'while'.

my input file looks like this
Nov 15 03:06 /export/home/pp_adm/inbound//mco_order_20111115.txt
Nov 15 03:06 /export/home/pp_adm/inbound//qc_mco_order_20111115.txt

i want to it to be print in one line not as below.
Nov
15
02:16
/export/home/pp_adm/inbound//mco_order_20111115.txt

thanks for your quick reply

Please post the code. Thanks.

Hi Scott,

After i change the IFS value, it is working as i expect it to...

old_IFS=$IFS;
IFS=$'\n';
while read line
 do
      cat $line |  awk '$3 < $D { print $4 }' | sed 's/.\{13\}$//g' >> dynamic_DF.txt;
 done < /export/home/afahmed/Arrvial_time.txt
IFS=$old_IFS;

Anyways Thanks

That code makes little sense. Where did you get it and what is it's purpose?

hmmmm... this code id very confusing. What's the meaning/value of '$D' in awk? Why do you need to do 'cat $line' into awk?
I'm confused.....
Given your sample file posted previously [re-post, please], what's the desired output once again?

That's a useless use of... everything...

You might as well have done

awk '{ ... }' filename > dynamic_DF.txt