If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Deleting blank in file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-25-04, 10:51
Moustifay Moustifay is offline
Registered User
 
Join Date: May 2004
Posts: 5
Deleting blank in file

Hi!

I want to format this file using unix commande sed or else
>
> 1505
> 1506
So that it looks like
>1505
>1506

Thanks for your help
Reply With Quote
  #2 (permalink)  
Old 05-25-04, 10:54
Moustifay Moustifay is offline
Registered User
 
Join Date: May 2004
Posts: 5
it's not clear in the post but my file contain a first blank line that i manage to delete thanks to sed "1d"
But after that the number are precieded by a blank too this way
blankblankblank1505
blankblankblank1506

How can i delete the blank in the second,the third and so one in the file to format the file like
1505
1506
1507
...
Reply With Quote
  #3 (permalink)  
Old 05-25-04, 11:49
iaguigon iaguigon is offline
Registered User
 
Join Date: May 2004
Location: Barcelona, Spain
Posts: 54
Quote:
Originally Posted by Moustifay
it's not clear in the post but my file contain a first blank line that i manage to delete thanks to sed "1d"
But after that the number are precieded by a blank too this way
blankblankblank1505
blankblankblank1506

How can i delete the blank in the second,the third and so one in the file to format the file like
1505
1506
1507
...
See man sed for an explanation on option s/regexp/replacement
You can look up man grep for help on regular expressions too.

Cheers
Reply With Quote
  #4 (permalink)  
Old 05-25-04, 16:34
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
You can remove all blank lines from a file (say sample_file.txt) by doing :

sed '/^$/d' sample_file.txt

Hope this is what you needed
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On