Skip to main content

Thread: using grep awk or any other unix tool to rearrange a file


i have file have few lines below:
#s 1 some-test
#d some-test
#m some-test
#x 10 steps ( 20)
#n 4
#l b c
1 2 3
4 5 6
7 8 9
#r 17 11 12

#s 2 some-test
#d some-test
#m some-test
#x 30 steps ( 30)
#n 4
#l b c
1 2 3
4 5 6
7 8 9
#r 10 11 12

#s 3 some-test
#d some-test
#m some-test
#x 30 steps ( 30)
#n 4
#l b c
1 2 3
4 5 6
7 8 9
#r 10 11 12

#s 4 some-test
#d some-test
#m some-test
#x 30 steps ( 30)
#n 4
#l b c
1 2 3
4 5 6
7 8 9
#r 10 11 12
from above file, each section marked "#s", want save number/texts marked bold+underline+red in color 1 line below:
html code:
#s 1 10 20 17 11 12 text #s 2 ... this
i can use grep , awk take out texts single line not know how put texts line below same file in destination: i.e., not know how put texts in line starting "#s" , "#x" in 1 single line in output file. also, there no space between ending of number in bracket , closing bracket, e.g., "( 20) in #s 1" .please help.

no grep needed; awk. pseudo-code:


/#s/ { put info variable-s }
...
/#r/ { print everything, plus info line }


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] using grep awk or any other unix tool to rearrange a file


Ubuntu

Comments

Popular posts from this blog

Thread: Can not create raid array: mdadm: no raid-devices specified.

Thread: HOW TO: Package and theme GTK+ / Gtkmm apps in Linux for Windows

Thread: Twinview issues