Substitution with sed + bash function

后端 未结 7 1998
一向
一向 2021-01-03 02:26

my question seems to be general, but i can\'t find any answers.

In sed command, how can you replace the substitution pattern by a value returned by a simple bash fun

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-03 03:05

    Agree with Glenn Jackman. If you want to use bash function in sed, something like this :

    sed -rn 's/^([[:digit:].]+)/`date -d @&`/p' file |
    while read -r line; do
        eval echo "$line"
    done
    

    My file here begins with a unix timestamp (e.g. 1362407133.936).

提交回复
热议问题