How to derive current date and time and append at the end of each line that contains 'Hello'

后端 未结 8 1611
谎友^
谎友^ 2021-02-07 04:08

I have the following file party.txt that contains something like the following:

Hello Jacky
Hello Peter
Bye Johnson
Hello Willy
Bye Johnny
Hello Mar         


        
8条回答
  •  佛祖请我去吃肉
    2021-02-07 04:22

     awk 'BEGIN{"date +'%Y-%m-%d'"|getline d;}/Hello/{print $0,d}' file
    

    will give you:

    Hello Jacky  2012-09-11
    Hello Peter 2012-09-11
    Hello Willy 2012-09-11
    Hello Mary 2012-09-11
    Hello Wendy 2012-09-11
    

提交回复
热议问题