I have a repeating list of this text, and the "testestewst" is unique for e开发者_如何学Goach item in the list:
testestetet *testest = [testeeste qtestest:@"I need this text"];
[testesteste:@"I need this text"];
[stesteset atestestest];
How in the world do I do a SED replace to remove everything but the text I need?
sed 's/.*"\(.*\)".*/\1/g' < test > result
works at least if you only one of such item per line... (replace 'test' and 'result' with the names of input and output files.
EDIT :
sed 's/^[^"]*$//g' < test | sed 's/.*"\(.*\)".*/\1/g' > result
Replaces also all lines without quotes with new lines...
If I understand what you are asking for, this should work...I went to some trouble to only return quoted text on lines containing an @. If your goal can be accomplished by just pulling out quoted text then it's possibly simpler.
$ cat > t1.sed
/@/{
s/[^"]*@"//
s/".*//
p
}
d
$ sed -f t1.sed t1.dat
I need this text
I need this text
$
sed -n '/"/!{/\n/{P;b}};s/"/\n/g;D' inputfile
Example:
$ cat inputfile
aaa bbb "this is" eee
fff "what I" hhh
111 "want"
"to see"
222 333
"today" zzz
$ sed -n '/"/!{/\n/{P;b}};s/"/\n/g;D' inputfile
this is
what I
want
to see
today
精彩评论