Consider the file test.txt
:
#include "foo.h"
#include "bar.h"
#include "baz.h"
using GNU sed version 4.2.1 (on Ubuntu 10.04.4 LTS), I can extract foo.h, bar.h and baz.h with:
SHELL$) sed -n -e 's:^\s*\#include\s*"\(.*\)".*:\1:p' test.txt
foo.h
bar.h
baz.h
using BSD sed (on Mac OS X lion), and modifying the above command, I can extract foo.h, bar.h and baz.h, but with double quotes:
SHELL) sed -n -e 's:^\s*\#include\s*\(.*\).*:\1:p' test.txt
"foo.h"
"bar.h"
"bar.h"
How can to extract names without the quotes with BSD sed? The output of theses commands are empty:
SHELL) sed -n -e 's:^\s*\#include\s*"\(.*\)".*:\1:p' test.txt
SHELL) sed -n -e 's:^\s*\#include\s*\"\(.*\)\".*:\1:p' test.txt
tr '"' ' '
) before applying your sed command. – mouviciel