Awk Script for Personal Markup


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk Script for Personal Markup
# 1  
Old 12-19-2011
Awk Script for Personal Markup

input:
Code:
----

blablablabla foofoofooo

nothing foo never never
nothing foo ever forever

	foo bar foo
	moo bar moo

	status quo

blablabla never foo

	moo bar moo

blablabla pehh

----


desired ouput:
Code:
----

* blablablabla foofoofooo

*<2-n> nothing foo never never
*<2-n> nothing foo ever forever

<[cd]
	[<3-n>foo bar foo]
	[<3-n>moo bar moo]
[cd]>

<[cd]
	[<4-n>status quo]
[cd]>

*<5-n> blablabla never foo

<[cd]
	[<6-n>moo bar moo]
[cd]>

*<n> blablabla pehh

----


- n is number of records seperated with one or more blank lines

- dashes are delimiter pattern for counting records

- [cd] tagged records identified by tab indentation

- what i can't handle is to assign record count properly to a awk variable ?

thx for help.
# 2  
Old 12-19-2011
Quote:
Originally Posted by uterwer
what i can't handle is to assign record count properly to a awk variable ?
How are you trying to use it? You should be able to get the record number directly from NR (or FNR).
# 3  
Old 12-19-2011
hi ; use NR but can't manipulate nested code (conditional loop) for (pattern matching + variable assignment).

awk only used for simple operations before.
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add markup tag and sequential number after specific line

Hello, This one has me a bit stumped. I have data the looks like, M END > <PREDICTION_ACCURACY> PROBABLE > <NO_OF_PARENTS> 3 > <CLOGP> -13.373 > <SMILES> OCC(O)C(OC1OC(CO)C(OC2OC(CO)C > <MIMW> 1006.322419888 (3 Replies)
Discussion started by: LMHmedchem
3 Replies

2. Shell Programming and Scripting

Shell script for sending automatic email to personal mail id

hi guys, I need a shell script to send mail automatically to my personal mail id like xxxx@hotmail.com but while experimenting with "mail" command I faced following problems. cat text1.txt | mail -s 'test mail' xxxx@hotmail.com command successfully executed but while checking for... (4 Replies)
Discussion started by: rrd1986
4 Replies
Login or Register to Ask a Question