How can I extract first column (the first column in "")
"xxxxx1" {685a}
"xx2" {bcdd}
"xx3 gsdd" {29a6ff}
"sdsdf xxx" {243b9}
"sdfsdf ccc dd" {c28f2f}
"dsdsf sfsdf" {216e}
"sdfsdfsd" {48530}
"sdfsdff" {9d2afa0n}
"sdfsdfdff sdfs" {d8681a}
"sdfsdsds sdfsdf d" {5b9b8}
"sdfsdfs sdf sdfsdf" {68e08a}
"sdfsdfsdf sdf" {107fa0}
what I want to have as result is this:
"xxxxx1"
"xx2"
"xx3 gsdd"
"sdsdf xxx"
"sdfsdf ccc dd"
"dsdsf sfsdf"
"sdfsdfsd"
"sdfsdff"
"sdfsdfdff sdfs"
"sdfsdsds sdfsdf d"
"sdfsdfs sdf sdfsdf"
"sdfsdfsdf sdf"
any idea?
Use
{
(space, brace) as the field delimiter, since you don't care about the second field:If you just want everything between the first and last
"
double-quote character of each line, the most simple solution would probably be this, usinggrep
instead ofawk
:The
-o
switch letsgrep
output only the matching parts instead of the whole line that contains the match. The (single-quoted, to prevent shell interpretation) pattern".*"
matches a sequence of any character (.
) with any length (*
), including zero, that is surrounded with double-quotes.As an alternative to muru's
awk
solution.using
cut
:using
grep
:or
using
sed
:or
or even:
Perl with grouping
(.*)
can do it too:The trick here is that we match whole line, and use
"(.*)"
to treat everything between double quotes as one group. We replace that whole line with the group we matched by referring to it via\1
part.