Saturday, September 4, 2021

How to replace pattern with shell command's output using matched pattern

Use case at hand: replace Unix timestamps with date/time in a log file:

[1630720618] unbound[63495:0] info: 127.0.0.1 foo.bar.com AAAA IN
[1630720618] unbound[63495:1] info: 127.0.0.1 foo.bar.com A IN
...

The shell command I'd apply is `date -r <timestamp>`. How would you
perform the substitution?

The desired output is:

[Sat Sep 4 03:56:58 CEST 2021] unbound[63495:0] info: 127.0.0.1 foo.bar.com AAAA IN
[Sat Sep 4 03:56:58 CEST 2021] unbound[63495:1] info: 127.0.0.1 foo.bar.com A IN
...

Thanks,
Life.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/sgvdf3%2413g6%241%40ciao.gmane.io.

No comments: