Hello !!
i have a text file, from where i have to perform an operation such as awk for every lines.
i can count the number of lines with cat filename | wc -l , no problem with that.
my scenario:
i take a input from a file, i count the length ofcertian paramater with substring and do the if else condition.
but i have to perform this action in every line....
a code snippet...
echo $File
#count =$( cat /home/postgres/edt1/$File-spice-7676.txt.edt1 |wc -l)
#echo $count
#while [ "$count" != $check ]
#do
#count=$count-1
for LINE in $( cat /home/postgres/edt1/$File-spice-7676.txt.edt1 )
do
v=$(awk -F "|" '{ print length($2)}' /home/postgres/edt1/$File-spice-7676.txt.edt1)
echo $v
if [ $v -lt $X ]
then
awk -F"|" '{print $1"|"substr($2, length($2)-6,length($2))"| "$3"|"$4}' /home/postgres/edt1/$File-spice-7676.txt.edt1 >> /home/postgres/edt1/test.txt
echo " inside less"
else
echo " no"
awk -F"|" '{print $1"|"$2"|"$3"|1 |"$4}' /home/postgres/$File-spice-7676.txt.edt > /home/postgres/edt1/test.txt
fi
done
..........
i am not able to proceed with LINE as it thinks as a new line when it finds spaces within a line,
i tried to count the number of lines in the file and think of decresing its value evey time, but also i didnt get the result
my file /home/postgres/edt1/$File-spice-7676.txt.edt1 )
is sum wot like that...
2008-04-18 11:11:52|+97798 04808287|spice-6464|16|
2008-04-18 11:11:52|spice-7676|+977980480 8287|16|
2008-04-18 11:12:43|+97798 04808287|spice-6464|16|
2008-04-18 11:12:43|spice-7676|+977980480 8287|16|
2008-04-18 11:14:04|+97798 04808287|spice-6464|16|
so how can i perform this task
thanks for any suggestion
with regards,
Creeds
i have a text file, from where i have to perform an operation such as awk for every lines.
i can count the number of lines with cat filename | wc -l , no problem with that.
my scenario:
i take a input from a file, i count the length ofcertian paramater with substring and do the if else condition.
but i have to perform this action in every line....
a code snippet...
echo $File
#count =$( cat /home/postgres/edt1/$File-spice-7676.txt.edt1 |wc -l)
#echo $count
#while [ "$count" != $check ]
#do
#count=$count-1
for LINE in $( cat /home/postgres/edt1/$File-spice-7676.txt.edt1 )
do
v=$(awk -F "|" '{ print length($2)}' /home/postgres/edt1/$File-spice-7676.txt.edt1)
echo $v
if [ $v -lt $X ]
then
awk -F"|" '{print $1"|"substr($2, length($2)-6,length($2))"| "$3"|"$4}' /home/postgres/edt1/$File-spice-7676.txt.edt1 >> /home/postgres/edt1/test.txt
echo " inside less"
else
echo " no"
awk -F"|" '{print $1"|"$2"|"$3"|1 |"$4}' /home/postgres/$File-spice-7676.txt.edt > /home/postgres/edt1/test.txt
fi
done
..........
i am not able to proceed with LINE as it thinks as a new line when it finds spaces within a line,
i tried to count the number of lines in the file and think of decresing its value evey time, but also i didnt get the result
my file /home/postgres/edt1/$File-spice-7676.txt.edt1 )
is sum wot like that...
2008-04-18 11:11:52|+97798 04808287|spice-6464|16|
2008-04-18 11:11:52|spice-7676|+977980480 8287|16|
2008-04-18 11:12:43|+97798 04808287|spice-6464|16|
2008-04-18 11:12:43|spice-7676|+977980480 8287|16|
2008-04-18 11:14:04|+97798 04808287|spice-6464|16|
so how can i perform this task
thanks for any suggestion
with regards,
Creeds
Comment