Operating System - HP-UX
1833445 Members
3679 Online
110052 Solutions
New Discussion

Re: script for inserting form feeds into file

 
james gould
Frequent Advisor

script for inserting form feeds into file

Need to write a script that will insert
form feed every 36 lines. Any suggestions?
4 REPLIES 4
Sridhar Bhaskarla
Honored Contributor

Re: script for inserting form feeds into file

Hi,

Did you look at the command pr?. Look at it's man page.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
harry d brown jr
Honored Contributor

Re: script for inserting form feeds into file

as in "pr -l36" where "-l36" is "dash el (lower case L) 36".

live free or die
harry
Live Free or Die
Darrell Allen
Honored Contributor

Re: script for inserting form feeds into file

Hi James,

The following will insert a FF after every 36 lines of the input file. The FF will be the first character of each line following the 36th line. If you want it to be on a line by itself, change the echo to: echo "\013" (leave off the \c")

# Begin script
ctr=0
while read line
do
echo $line
ctr=`expr $ctr + 1`
if [ $ctr -eq 36 ]
then
echo "\013\c"
ctr=0
fi
done out

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)
Darrell Allen
Honored Contributor

Re: script for inserting form feeds into file

I'm sorry, I misread the ascii table. Please change 013 in my answer to 014.

Thanks,
Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)