linux - sed place parentheses at the beginning and close on the 4th line -
im trying place open parenthesis on first line , close end of 4th line. below example of data followed output looking for.
tester1 service_ticket_created thu mar 19 23:27:57 utc 2015 192.168.1.3 tester2 service_ticket_created fri mar 20 00:31:59 utc 2015 192.168.1.2
(tester1 service_ticket_created thu mar 19 23:27:57 utc 2015 192.168.1.3) (tester2 service_ticket_created fri mar 20 00:31:59 utc 2015 192.168.1.2)
using awk
can as
awk 'nr%4==1{print "("$0; next} nr%4==0{print $0")"; next}1'
test
$ awk 'nr%4==1{print "("$0; next} nr%4==0{print $0")"; next}1' input (tester1 service_ticket_created thu mar 19 23:27:57 utc 2015 192.168.1.3) (tester2 service_ticket_created fri mar 20 00:31:59 utc 2015 192.168.1.2)
shorter version
awk 'nr%4==1{$0="("$0} nr%4==0{$0=$0")"}1'
Comments
Post a Comment