Link to home
Start Free TrialLog in
Avatar of mrbungle50
mrbungle50Flag for Australia

asked on

Need to output every second line in a text file

Hello all,
I need to run a short script of some sort that looks through a text file of a variable sze and take every second line and output this to a new file.
The one catch? is the original file cannot be left with a blank line where the line was extracted
I was looking at a cut -c or maybe an AWK command but can't figure how to gte it to skip a line each time?
the file will be like this:
The quick brown fox jumps over the lazy dog
The slow black dog jumps over the lazy fox
The quick brown fox jumps over the lazy dog
The slow black dog jumps over the lazy fox
The quick brown fox jumps over the lazy dog
The slow black dog jumps over the lazy fox
The quick brown fox jumps over the lazy dog
The slow black dog jumps over the lazy fox
The quick brown fox jumps over the lazy dog
The slow black dog jumps over the lazy fox
The quick brown fox jumps over the lazy dog

I want to have to two files with no blank lines.
One containing "The quick brown fox jumps over the lazy dog" and
the 2nd has "The slow black dog jumps over the lazy fox"
Thanks in advance
Craig
MrBungle50
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrbungle50

ASKER

Absolutely fabulous and the syntax makes sense.  I must be learning something from this as I go :-)
Thanks Ozo  you are a champion script writer. I wish you worked in my office.
Thanks again