The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help : crisis situation !! Eisa UNIX for Dummies Questions & Answers 5 01-11-2008 03:17 AM
strange situation in file arunkumar_mca High Level Programming 0 11-13-2007 06:09 AM
sed situation Laurel Maury Shell Programming and Scripting 4 10-05-2006 01:19 PM
sed substitute situation newbreed1 UNIX for Dummies Questions & Answers 16 06-03-2005 02:26 PM
current situation joanne6298 UNIX for Advanced & Expert Users 2 08-06-2003 10:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-25-2007
vishalpatel03 vishalpatel03 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 33
How to Sort a file for given situation?

Hi
All,

How can you sort a file that is doubled space ( where even number lines are blank lines) and still preserves the blank lines?
You can use grep,sed and regular expression.

Thanks
Vishal
  #2 (permalink)  
Old 11-25-2007
gus2000 gus2000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 157
Well...you can't. All you can do is sort the file and then put the doublespacing back.

Code:
sort foo.bar | sed '/^$/d;G'
  #3 (permalink)  
Old 11-25-2007
vishalpatel03 vishalpatel03 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 33
can you please explain how it works?

Can You please explain with example like what type of content in foo.bar and how it work?

Thanks
Vishal
  #4 (permalink)  
Old 11-25-2007
gus2000 gus2000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 157
Hmmm, I think you'll learn it better if you just try it out yourself. But:

/^$/ matches blank lines (beginning of line followed by end of line)

d; deletes the line(s) that matched the pattern; starts a new command

G adds a newline

Good luck with the rest of your homework.
  #5 (permalink)  
Old 11-26-2007
V3l0 V3l0 is offline
Registered User
  
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
I don't understand the question

Are you able to use 'sort' ?
Please give me an example.

Thx
Closed Thread

Bookmarks

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

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




All times are GMT -4. The time now is 09:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0