- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to pad out lines of text?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2003 02:09 PM
07-09-2003 02:09 PM
I have an application that transfers check clearing information to the bank using a modem. Each line of output must consist of exactly 80 characters followed by a CR-LF. My input file varies in length although every line is less than 80 characters. Each input line ends in a single linefeed. I would like to read the input one line at a time and remove the linefeed. Next append spaces until I reach 80 characters. Finally, I need to output the carriage return - linefeed characters.
Input file:
LOGDXARC 5865002572IYS1 000000000 C00000000000000
1HDR -001 12299-051 876500187232311819N CARD
000001256700000100008765001572122899
000001256800001769978765001572122899
000001256900000042808765001572122899
000001257000000369188765001572122899
000001287900005547818765001572122899
000001288000006997878765001572122899
000001288100000166928765001572122899
000001288200000544488765001572122899
000001288300000845008765001572122899
000001288400000006078765001572122899
000001288500000300008765001572122899
000001288600000337188765001572122899
000001288700000160218765001572122899
000001288800002493478765001572122899
000001288900000595388765001572122899
000001289000001051688765001572122899
1EOF 00319 00040605190113047345
----------------------------
I'm thinking of using sed but I can't seem to get the syntax right.
Can anyone get me started?
Thanks,
Bob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2003 02:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2003 02:14 PM
07-09-2003 02:14 PM
Re: How to pad out lines of text?
perl -n -e 'chomp; printf("%-80.80s\r\n",$_)' < infile > outfile
No points for this one, please.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2003 02:16 PM
07-09-2003 02:16 PM
Re: How to pad out lines of text?
The awk example was missing a quote (though I 'spect you could have figured that out):
awk '{ printf("%-80.80s\r\n",$0) }' < infile > outfile
No points again, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2003 02:46 PM
07-09-2003 02:46 PM
Re: How to pad out lines of text?
Thanks!! I used the perl method. Is there an easy way to check the output without having to count all the spaces?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2003 02:49 PM
07-09-2003 02:49 PM
Re: How to pad out lines of text?
od -v -Ad -ta outfile | pg
Man od for details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2003 02:57 PM
07-09-2003 02:57 PM
Re: How to pad out lines of text?
Thanks!!! Od worked and the file looks perfect!!!
Bob