i have text files named like vho1.txt, vho2.txt... vho15.txt.In all there are 15 in number.
each file has strings like
\Movies On Demand\Action & Adventure|X-Men: Wolverine|2009-09-29 00:01:00|2010-03-24 23:59:00|Active|3
\Movies On Demand\Free\Free1|My movie 14|2010-01-11 00:00:00|2010-03-01 23:59:59|Active|4
i have to introduce pipes in the same string after the second pipe(|) depending on the number at the last column (if the number is 3, it should have 3 ||| in that string, if 4 , |||| pipes).
\Movies On Demand\Action & Adventure|X-Men: Wolverine||||2009-09-29 00:01:00|2010-03-24 23:59:00|Active|3
\Movies On Demand\Free\Free1|My movie 14|||||2010-01-11 00:00:00|2010-03-01 23:59:59|Active|4
Thanks for the answers. i have tried like this but it didn't work
#looping through all the files VHO1.txt,VHO2.txt....
for i in `ls VHO?.txt`
do
#getting the last column value
var2=echo $i|cut -f 6 -d "|" $i
# this is done to conditonally insert the pipes in each line based on the last column value.
if [ $var2 -eq 3 ]
then
#inserting the pipes as suggested and redirecting to file
awk -F"|" '{printf "%s|%s",$1,$2}{for(i=0;i<=$NF;i++){printf "|"}}{printf "%s|%s|%s|%s\n",$3,$4,$5,$6}', $i > F$
fi
done
pls. correct me where it is wrong.it just prints last column value on the console..