grt=`sort -nr line_count.txt|head -1`
while read $dline
do
if [ "$grt" -eq "`wc -l combo_operncount.$dline|awk '{print $1}'`" ]
then
awk -F, '{print $1}' combo_operncount.$dline > FULLD7
else
echo combo_operncount.$dline >> filecoll.txt
fname=`cat filecoll.txt|tr -s "\n" " "`
echo $fname
#paste FULLD7 combo_operncount.$dline
fi
done
[/CODE]
Error is thrown where it is highlighted
busyboy
February 15, 2013, 6:13am
2
try assinging the value of the
wc -l
to a variable before going to test.
Also enclose the variable $dline inside ""
~# grt=`sort -nr filename|head -1`
~# JJ=`wc -l filename."$KK"| awk '{ print $1 }'`
~# if [ "$grt" == "$JJ" ]; then echo $JJ; else echo "Not true"; fi
Not true
I dint get wat u aiming to explain....
busyboy
February 15, 2013, 6:28am
4
comparing two numbers should be done via
==
rather than
-eq
, as well. rest is for your understanding .
Wrong.
==
is for string comparison and -eq
is for numeric comparison.
RudiC
February 16, 2013, 6:35am
6
I can't see where the while loop in your script in post #1 reads from; as is it would read from stdin which might be your terminal. Are you sure the variable dline
holds a valid file name?
alister
February 16, 2013, 9:51pm
7
If you don't want wc to print a filename, don't provide one as an argument. Instead, redirect the command's standard input:
wc -l < filename
Regards,
Alister