Results 1 to 3 of 3
Hello all,
I have a question regarding a bash script:
how can I read a file and put in a array all the lines that are after each blank lines.
...
- 07-21-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 4
bash script to select lines
Hello all,
I have a question regarding a bash script:
how can I read a file and put in a array all the lines that are after each blank lines.
ex:
aaa
111
bbb
222
333
ccc
555
put in the array only aaa bbb ccc
- 07-21-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
welcome to the forum
if the input file is called "w" then this seems to work OK
awk 'BEGIN {ORS=" "};/^$/{getline a; print a}' <w
the regular expression "^$" matches empty lines;
with the Output Record Separator reset to blank
(from newline) we get the next lines concatenatedthe sun is new every day (heraclitus)
- 07-21-2009 #3


Reply With Quote
