afahmed
November 16, 2011, 3:49am
1
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?
Scott
November 16, 2011, 3:58am
2
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
afahmed
November 19, 2011, 1:08pm
3
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
Scott
November 19, 2011, 1:13pm
4
Please post the code. Thanks.
afahmed
November 19, 2011, 4:22pm
5
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
Scott
November 19, 2011, 4:31pm
6
That code makes little sense. Where did you get it and what is it's purpose?
afahmed:
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
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?
afahmed:
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's a useless use of... everything...
You might as well have done
awk '{ ... }' filename > dynamic_DF.txt