UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old February 23rd, 2005, 09:24 AM
zlutovsky zlutovsky is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Prague, Czech Rep.
Posts: 117 zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 42 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by dsshed
Hi

i have data in files as shown below.

this is line one.

this is line two.


this is line four.
this is line five.

i have got rid of the empty lines by running the command sed '/^$/d'
and getting the file to the format below



this is line one.
this is line two.
this is line three.
this is line four.
this is line five.

i am asking your help/advise to end up with a file
format as below.

this is line one.this is line two.this is line three.this is line four.this is line five.

basically from the original file that i have, i want to get rid
of all the blank lines and then i want to get rid of all
new line charaters and stich all lines into one BIG SINGLE line
of data.

thanks for your time



What about a simple C program? You can write it as you wish and need not guess and try how the system commands work with huge files:

#include<stdio.h>

int main(int argc, char* argv[])
{
int c;

while ((c = fgetc(stdin)) != EOF) {
if (c != '\n')
fputc(c, stdout);
}
}

You can of course add test for succesfull read, return the completion code ...

Regards

Reply With Quote
  #17  
Old February 23rd, 2005, 09:30 AM
zlutovsky zlutovsky is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Prague, Czech Rep.
Posts: 117 zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 42 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by dsshed
Hi

i have data in files as shown below.

this is line one.

this is line two.


this is line four.
this is line five.

i have got rid of the empty lines by running the command sed '/^$/d'
and getting the file to the format below

this is line one.
this is line two.
this is line three.
this is line four.
this is line five.

i am asking your help/advise to end up with a file
format as below.

this is line one.this is line two.this is line three.this is line four.this is line five.

basically from the original file that i have, i want to get rid
of all the blank lines and then i want to get rid of all
new line charaters and stich all lines into one BIG SINGLE line
of data.

thanks for your time



What about a simple C program? You can write it as you wish and do not need to guess how the system tools work with huge files:

#include<stdio.h>


int main(int argc, char* argv[])
{
int c;

while ((c = fgetc(stdin)) != EOF) {
if (c != '\n')
fputc(c, stdout);
}
}

You can of course add test for reading errors, return the return code and and and...

Regards

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > line stiching


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT