You are not logged in.

#1 2009-08-19 13:08:27

mrpringle
Member
Registered: 2009-07-11
Posts: 74

awk command

Hi,
Unfortunately I really don't have the time to learn awk.

I need a command which scans a file and prints a subset of the line when a match is found.

Here are the specifics.

When a line containing the following is found. I need to print /some/path. I only want to consider the first match and any other lines not matching should be ignored.
DocumentRoot "/some/path"

How can this be done?

Thanks

Offline

#2 2009-08-19 13:19:27

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: awk command

awk -F '"' '/^DocumentRoot/ {print $2}' /path/to/file.txt | head -n1

Offline

#3 2009-08-19 13:52:39

mrpringle
Member
Registered: 2009-07-11
Posts: 74

Re: awk command

Thank you very much for that.

Offline

Board footer

Powered by FluxBB