mrbungle50
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Ozo you are a champion script writer. I wish you worked in my office.
Thanks again