[Email protected] ~]# forLineinch`Cat/etc/passwd`; Do Echo$line |awk '{print $ "" Strftime ("%y-%m-%d%h:%m:%s", Systime ())}'&&Sleep 2; Doneroot:x:0:0: Root:/root:/bin/bash .- ,- - One: the: onbin:x:1:1: Bin:/bin:/sbin/nologin .- ,- - One: the:Genevadaemon:x:2:2:d Aemon:/sbin:/sbin/nologin .- ,- - One: the: toadm:x:3:4: Adm:/var/adm:/sbin/nologin .- ,- - One: the: -LP: x:4:7:LP:/var/spool/lpd:/sbin/nologin .- ,- - One: the: theSync: x:5:0:Sync:/sbin:/bin/Sync .- ,- - One: the: Oneshutdown:x:6:0: Shutdown:/sbin:/sbin/shutdown .- ,- - One: the: -..................................... [[Email protected]~]#Ping-C5www.baidu.com |awk '{print $ "" Strftime ("%y-%m-%d%h:%m:%s", Systime ())}'PING www.a.shifen.com (14.215.177.38) About( -) bytes of data. .- ,- - One: $: - -Bytes from14.215.177.38: icmp_seq=1Ttl= Wu Time=7.35Ms .- ,- - One: $: - -Bytes from14.215.177.38: icmp_seq=2Ttl= Wu Time=6.75Ms .- ,- - One: $: Wu -Bytes from14.215.177.38: icmp_seq=3Ttl= Wu Time=6.83Ms .- ,- - One: $: - -Bytes from14.215.177.38: icmp_seq=4Ttl= Wu Time=6.85Ms .- ,- - One: $: About -Bytes from14.215.177.38: icmp_seq=5Ttl= Wu Time=5.84Ms .- ,- - One: $: $ .- ,- - One: $: $---www.a.shifen.comPingStatistics--- .- ,- - One: $: $5Packets Transmitted,5Received0% packet loss, Time4013ms .- ,- - One: $: $Rtt min/avg/max/mdev =5.840/6.727/7.358/0.503Ms .- ,- - One: $: $
Linux Awk adds a timestamp after each line of the file