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

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -