You are not logged in.

#1 2005-04-11 16:17:52

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

generic bash parsing

Ok, so I'm confusing myself alot... too much grep / sed / awk...

I have a file which I want to parse in bash:

hello = "goodbye"
test =  "this line is
continued"

I can't seem to force sed, or anything else, to work with the line continuation...
maybe I can pre-parse it and remove newlines that have a "" before it... *shrug*
any help?

Offline

#2 2005-04-11 17:40:53

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: generic bash parsing

as you asked for new line removal, someone posted a link to advanced sed tricks, maybe you could modidy the one for newline-removal to remove only \n (in c-notation).

Offline

#3 2005-04-11 17:43:37

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: generic bash parsing

yeah, I would remove the newlines first..

sed '/\[ ]*$/N;s|\[ ]*n| |g'

"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#4 2005-04-11 17:48:12

cmp
Member
Registered: 2005-01-03
Posts: 350

Re: generic bash parsing

I don't think that every new line should be removed, but this should do the trick (remove newline directly preceeded by a slash):

sed ':a;N;$!ba;s/\n//g'

but don't ask me how it works wink - just copy and paste programming (I modified one script)

Offline

Board footer

Powered by FluxBB