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

后端 未结 8 1593
谎友^
谎友^ 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 04:36

    In gawk only:

    $ gawk '/Hello/ {print $0, strftime("%Y-%m-%d");}' party.txt 
    Hello Jacky 2019-09-17 
    Hello Peter 2019-09-17 
    Hello Willy 2019-09-17 
    Hello Mary 2019-09-17 
    Hello Wendy 2019-09-17 
    

提交回复
热议问题