[CentOS] Need help with awk one-liner
Mikael Fridh
mikael.fridh at its.uu.se
Thu Jul 10 08:39:36 UTC 2008
On Wed, Jul 09, 2008 at 12:13:13PM -0500, Sean Carolan wrote:
> The awk output that was piped into to the sed command looks like this:
>
> ajpv12://host1.domain.company.com:8008/root
> ajpv12://host2.domain.company.com:8008/root
> ajpv12://host3.domain.company.com:8008/root
awk '/:8008\/root/ {printf "%s\t", gensub(/ajpv12:\/\/(.*):8008\/root/, "\\1", 1, $3) } END { printf "\n" }'
if you give an exact example of your input it would be easier but I
guess you can crunch the above example to do exactly what you want.
Match other ports and protocols:
awk '/:[[:digit]]+\/root/ {printf "%s\t", gensub(/\w+:\/\/(.*):[[:digit:]]+\/root/, "\\1", 1, $3) } END { printf "\n" }'
takes input:
foo bar URL baz
output:
URL\tURL\tURL\n
--
Fridh
More information about the CentOS
mailing list