From: Naylor, Jim (Jnaylor@Schnucks.com)
Date: Mon Mar 03 2003 - 10:14:06 EST
Thanks, to all that replied with. Here are their suggestions. All very
good: Original question at the end.
James Sohr:
#!/usr/local/bin/perl
use Text::ParseWords;
$PS_T="A465";
while $text=<STDIN>
{
print pack($PS_T,$text),"\n";
}
Bill Thompson:
for LINE in $(cat file); do
printf "%-465s\n" $LINE >>newfile
done
Eric Hunter:
typeset -L465 VARNAME=$LINE1
Bill Hassel:
typeset -L465 REPLY
cat file_name | while read REPLY
do
echo "$REPLY" >> some_output_file
done
Richard Wright:
Use the dd command with the blocking factor
James Lonski:
awk '{
FILLER=" "
SPACES = substr(FILLER,1,(79 - length($0)) )
printf ("%s%s|\n", $0, SPACES)
}' < ORIGFILE > NEWFILE
John Kingsland, Mike Keighley, David Ledger, Ed:
awk '{printf "%-465s\n",$0}' input_file > output_file
Bret Geer:
awk '
BEGIN { vREQUIRED = 465 }
(length ($0) <= vREQUIRED) { printf ("%s", %0)
for (vloop = length ($0) - 1; vloop <=
vREQUIRED; vloop++)
printf (" ")
printf ("\n")
}
' < inputfile > newfile
Corne Beerse:
sed -e 's/$/ \{465\}/' -e 's/^\(.\{465\}\)/\1/'
Quy Nguyen Dai:
Perl
Original Question:
Good Day All,
I though I could figure this out but I seem to be having a mental block. I
also searched the archives for some help but was unsuccessful. I have a
file with variable length records. I need to pad each record with space to
equal 465 length record.
Example File:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCC
First record has 30 "A's" . I need to add 435 spaces to the end of this
record.
Second Record has 65 "B's". I need to add 400 spaces to the end of this
record.
Third Record has 25 "C's". I need to add 440 spaces to the end of this
record.
And so on. I though I could do it with sed but I can't figure it out. Any
help would be greatly appreciated.
Thanks,
Jim Naylor
Unix Systems Administrator
Schnuck Markets, Inc.
* Direct: (314) 994-4784
*)) Cell: (314) 691-0186
* Fax : (314) 994-4684
* jnaylor@schnucks.com
-- ---> Please post QUESTIONS and SUMMARIES only!! <--- To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only) http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search)
This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:26 EDT