AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-11-2006, 03:28 PM
|
#1
|
|
LQ Newbie
Registered: Sep 2006
Posts: 3
Rep:
|
Need to Insert Newline Char
I have a large file that's come through without newlines. When I run a word count on it (wc) it lists 0 lines. I know it's got the data there - I can see it. But I need to break it up into individual records.
The record length is 241 characters and there should be over 16 million records. I first tried using the command 'fold' and it seemed to work, but when I 'wc' the resulting file it comes up with 1 less record than what it should come up with. And when I divide the total number of bytes by what the record length should be with the newline, I don't come up with and even number...so I know it's missing something somewhere (but only 1 byte - jeez!).
Any suggestions? Thanks, in advance for your help!
|
|
|
|
09-11-2006, 04:48 PM
|
#2
|
|
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 13.37
Posts: 4,084
Rep: 
|
If it's only 1 record less than it should be, could it be that the very last line doesn't end with a newline character?
|
|
|
|
09-11-2006, 08:45 PM
|
#3
|
|
LQ Newbie
Registered: Sep 2006
Posts: 3
Original Poster
Rep:
|
Quote:
|
Originally Posted by gilead
If it's only 1 record less than it should be, could it be that the very last line doesn't end with a newline character?
|
I think that is the case. Is there a way to put one after the last line? I'd like the record count to match the total number of records and right now it's showing up as 1 shy of the total.
|
|
|
|
09-11-2006, 09:31 PM
|
#4
|
|
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 13.37
Posts: 4,084
Rep: 
|
It's very clunky, but if all you're missing is the final newline (1 byte), then the following works on my box:
Code:
echo -e >> outputfile
The result is a blank line at the end of the file and a filesize that is increased by 1 byte - but it's not an elegant way to solve the problem.
|
|
|
|
09-12-2006, 08:34 AM
|
#5
|
|
LQ Newbie
Registered: Sep 2006
Posts: 3
Original Poster
Rep:
|
Thank you, Steve. That seems to have done the trick.
I appreciate your help! ~Anne
|
|
|
|
09-12-2006, 02:10 PM
|
#6
|
|
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 13.37
Posts: 4,084
Rep: 
|
No problem - I'm glad it's giving the results you wanted 
|
|
|
|
09-15-2006, 02:35 AM
|
#7
|
|
LQ Newbie
Registered: Mar 2004
Location: France
Distribution: Slackware
Posts: 6
Rep:
|
You can use fold witch insert a newline caracter at 80 (use fold -w 132 toto.txt > toto2.txt if you want to cut at 132 char.)
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:13 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|