Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catching a variable

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
Hallo All,

Don't know if this is possible, but here we go. I am trying to catch a string to use later in an awk script.

# Catch subject
/^Subject/ { $0 = KeepThis ; next}
# Rewrite subject
/^Subject/ { $0 = "Subject: NEW"
print; next}
.
.
.
print <original_subject>KeepThis</original_subject>

But this does not work, it prints literally 'KeepThis' and the #Rewrite subject seems to be ignored. Could someone refresh my tired mind?

 
Hi

Code:
[gray]# Catch subject[/gray]
/^Subject/ { [red]KeepThis = $0[/red] } [gray]# [maroon]no next here[/maroon][/gray]
[gray]# Rewrite subject[/gray]
/^Subject/ { $0 = "Subject: NEW"
print; next}
[gray].
.
.[/gray]
print [red]"[/red]<original_subject>[red]"[/red]KeepThis[red]"[/red]</original_subject>[red]"[/red]

Feherke.
 
Sigh.... now why didn't I catch that...


Thank you - have a star :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top