I have text file which has below linesFrom:   arkit Corp. <do-not-reply@123.ac>Sent:   Friday, June 16, 2017 6:35 PMTo:     User NameSubject:        arkit Corp.: activity alert.                 <http:// arkit.co.in/>ACTIVITY ALERT FOR:Ravihttps:// arkit.co.in/ Path Read (03/07/2017)Path: /website/upload/file.txthttps:// arkit.co.in/ Path Read (04/07/2017)Path: /website/upload/file1.txt        Copyright  2017 arkit Corp.. All Rights Reserved.I would like to print them as belowhttps:// arkit.co.in/ Path Read (03/07/2017) Path: /website/upload/file.txthttps:// arkit.co.in/ Path Read (04/07/2017) Path: /website/upload/file1.txtCan any one suggest how can i print side-by-side
Print matched pattern lines side by side
shell script
I you want to parse the whole message, use addresses like this:sed -n '/https:/h;/Path:/{H;g;s/\n/ /p;}' yourfileDon't output by default (-n). Put a line starting with https: in the hold buffer, then for the Path: line, append it to the hold buffer, move it to the pattern space and replace the newline with a whitespace.Or a different approach:sed -e '/^https:/!d;:a' -e '$!N;/Path:/!ba' -e 's/\n\n*/ /' yourfileThis means: If the line doesn't start with https:, delete it (/^https:/!d). Else start a loop (:a) to add new lines if there are any ($!N), until we added the Path: line. /Path:/!ba. Finally replace newlines with a whitespace to put everything in one line (s/\n\n*/ /).