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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if line end with \

Status
Not open for further replies.

menyl

Programmer
Oct 26, 2011
12
NL
HI all,

I want to check if a line end with \ ,if it does I need to attached the next line to it (with one space), with out the \ and so one for the next line. if its not I just need to print it
I must use awk for this. Im using this awk line just to check if the line end up with \ but I get an eror:

awk '{if($NF~/\/) print $1}' input.scs > input_mod.scs

can some one also provide some detales how to continue regarding the second part of the attachment??

thx

meny
 
Hi

Backslash ( \ ) has special meaning in regular expressions. To specify a literal backslash you have to escape it by prefixing with another backslash. Beside that, you should anchor it to the end of string with a dollar sign ( $ ).
Code:
awk '[teal]{[/teal][navy]ORS[/navy][teal]=[/teal][fuchsia]/\\$/[/fuchsia][teal]?[/teal][green][i]" "[/i][/green][teal]:[/teal][green][i]"[/i][/green][lime][i]\n[/i][/lime][green][i]"[/i][/green][teal];[/teal][b]sub[/b][teal]([/teal][fuchsia]/\\$/[/fuchsia][teal],[/teal][green][i]""[/i][/green][teal])[/teal][teal]}[/teal][purple]1[/purple]' input.scs > input_mod.scs
Tested with ##gawk## and ##mawk##.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top