Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 5
    The awk command is nice - but only if you've got spaces around the =. It won't work for POP3_SERVER_NAME=localhost. Commented Feb 14, 2016 at 11:07
  • 7
    @Marcel, You can change the delimiter used by awk from spaces to something else using -F. For instance: -F "=" will use = as a delimiter in the case you mention. Commented Apr 11, 2018 at 7:44
  • How can I print the value of a capture group with awk? For example, I expected something like awk '/POP3_SERVER_NAME = (.*)/ { print \1 }' test.dat Commented May 28, 2021 at 23:06
  • What is the second * for in the sed cmd? The first is for zero or more chars. Commented Oct 18, 2021 at 7:27
  • 1
    @Timo: The second * here means to match zero or more spaces following =. So it will print localhost given =localhost, = localhost, or = localhost. That seemed like a careful way to use sed here. Commented Oct 18, 2021 at 10:05