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

Well...you can't. All you can do is sort the file and then put the doublespacing back.

sort foo.bar | sed '/^$/d;G'

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

Thanks
Vishal

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.

I don't understand the question :confused:

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

Thx