
troy d. straszheim wrote:
I figured out what GNU sed's first complaint was, it doesn't like this:
macroname=`cat $file | grep '^//[] []*MACRO:' | sed 's/.*MACRO:[] []*\([]_A-Z0-9[]*\).*/\1/'`
but it does like this:
macroname=`cat $file | grep '^//[] []*MACRO:' | sed 's/.*MACRO:[] []*\([_A-Z0-9]*\).*/\1/'`
Doug, what are you trying to do here? If you're trying to extract "foo" from a line "<WHITESPACE>MACRO:<WHITESPACE>foo bar baz" then you should do it as: macroname=`sed -n ' /^[TAB ]*MACRO:/{ # Remove everything up to the beginning of # the first word after MACRO s/.*MACRO:[TAB ]*// # Remove everything after this word and # print to stdout. s/[^_A-Z0-9].*//p }' "$file"` where TAB is a literal TAB character Control-VControl-I. There's no need to invoke three process when you need only one and it's good practise to quote variables that expand to file names. Let me know if the above doesn't fit the bill and, if I can't figure it out myself I'll take it to the sed-users list. Regards, Angus