Blackbug
April 16th, 2012, 09:28 AM
hello i want an script which calculates number of lines from a file, and calculates in how many multiples of 128 lines are present.
Then for each set of 128 lines it writes output to a different file.
I have to do this because of the limitation of PS command in AIX. ps command in AIX displays only 128 resultset.
The code is not working and just a rough idea.
line=`wc -l $filename`
count=`expr $line / 128`
echo $count
num=0
while [ $count > 0 ]
do
i=1
num=`expr $i * 128`
head -$num $filename >$outputfile.$i
tail +$num+1 $filename > $outputfile.$i+1
i=`expr $i + 1`
count=`expr $count - 1`
done
I hope anyone can help on this.
Then for each set of 128 lines it writes output to a different file.
I have to do this because of the limitation of PS command in AIX. ps command in AIX displays only 128 resultset.
The code is not working and just a rough idea.
line=`wc -l $filename`
count=`expr $line / 128`
echo $count
num=0
while [ $count > 0 ]
do
i=1
num=`expr $i * 128`
head -$num $filename >$outputfile.$i
tail +$num+1 $filename > $outputfile.$i+1
i=`expr $i + 1`
count=`expr $count - 1`
done
I hope anyone can help on this.