tag:blogger.com,1999:blog-1255024703457423340.post1842421496407327871..comments2024-03-13T13:54:48.044+05:30Comments on The UNIX School: awk - Join or merge lines on finding a patternGuru Prasadhttp://www.blogger.com/profile/07898245472802947101noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-1255024703457423340.post-55961189415730366802015-07-30T23:12:09.212+05:302015-07-30T23:12:09.212+05:30awk '/^>/{a=$0;getline x;$0=a;}1' file...awk '/^>/{a=$0;getline x;$0=a;}1' fileGuru Prasadhttps://www.blogger.com/profile/07898245472802947101noreply@blogger.comtag:blogger.com,1999:blog-1255024703457423340.post-34020548729116479412015-07-30T17:00:56.889+05:302015-07-30T17:00:56.889+05:30hi so i have a problem that is kind of similar to ...hi so i have a problem that is kind of similar to this i have this <br />>@1M1U7:00212:00595<br />_F_48_30.5625<br />CAATGGGAAATCTTAGGCACTTCTTCCGGCGAATTTCGCGCCATTTCT<br />>@1M1U7:00241:00593<br />_F_48_30.3958333333<br />CAATGGGAAATCTTAGGCACTTCTTCCGGCGAATTTCGCGCCATTTCT<br /><br />and i want to get to this:<br />>@1M1U7:00212:00595_F_48_30.5625<br />CAATGGGAAATCTTAGGCACTTCTTCCGGCGAATTTCGCGCCATTTCT<br />>@1M1U7:00241:00593_F_48_30.3958333333<br />CAATGGGAAATCTTAGGCACTTCTTCCGGCGAATTTCGCGCCATTTCTAnonymoushttps://www.blogger.com/profile/06800934469845985176noreply@blogger.comtag:blogger.com,1999:blog-1255024703457423340.post-59535194071254654372015-04-10T17:51:22.570+05:302015-04-10T17:51:22.570+05:30Thanks a lot Guru!
This command is working fine in...Thanks a lot Guru!<br />This command is working fine in all situations except when input is like this:<br />START 1<br />START 2<br />Unix<br />Linux<br /><br />in this case, output is :<br />START 2~Unix<br />START 2~Linux<br /><br />but expected output is :<br />START 1<br />START 2~Unix<br />START 3~LinuxAnonymoushttps://www.blogger.com/profile/17796696986718886684noreply@blogger.comtag:blogger.com,1999:blog-1255024703457423340.post-59188537666527625162015-04-10T10:07:13.125+05:302015-04-10T10:07:13.125+05:30awk '/START/{x=$0;next}{print x"~"$0...awk '/START/{x=$0;next}{print x"~"$0;}' fileGuru Prasadhttps://www.blogger.com/profile/07898245472802947101noreply@blogger.comtag:blogger.com,1999:blog-1255024703457423340.post-32660180060910007972015-04-09T17:00:35.871+05:302015-04-09T17:00:35.871+05:30Hi Experts, I am trying to achieve below results. ...Hi Experts, I am trying to achieve below results. Please help:<br /><br />For Inputs:<br />START 1<br />UNIX<br />Linux<br />START 2<br />Solaris<br />Aix<br />SCO<br /><br />Output should be:<br />START 1~UNIX<br />START 1~Linux<br />START 2~Solaris<br />START 2~Aix<br />START 3~SCOAnonymoushttps://www.blogger.com/profile/17796696986718886684noreply@blogger.comtag:blogger.com,1999:blog-1255024703457423340.post-48106719637493600242013-08-23T09:28:01.035+05:302013-08-23T09:28:01.035+05:30Thanks for your help: i got it to work. I could no...Thanks for your help: i got it to work. I could not install dos2unix (using yum) because i don't yet know how to get access to my fedora linux root directory; however, someone gave me this dos2unix equivalent command which fixed my dos text input file: <br />tr -d '\r' < awk_merge_join_input_file > awk_merge_join_input_file_new<br /><br />So now when I do:<br /><br />awk '/START/{if (NR!=1)print "";next}{printf $0}END{print "";}' file<br /><br />I get the records sandwiched between the START pattern delimiters properly concatenated onto one line.<br /><br />Thanks !<br />Anonymoushttps://www.blogger.com/profile/06131903907203885364noreply@blogger.comtag:blogger.com,1999:blog-1255024703457423340.post-91483592911775129902013-08-08T07:38:41.362+05:302013-08-08T07:38:41.362+05:30Looks like your file contains ^M characters. Run t...Looks like your file contains ^M characters. Run the dos2unix command on your file before running the awk command.Guru Prasadhttps://www.blogger.com/profile/07898245472802947101noreply@blogger.comtag:blogger.com,1999:blog-1255024703457423340.post-79896556967346277682013-08-08T03:16:59.102+05:302013-08-08T03:16:59.102+05:30I'm a mainframe and SAS programmer trying to ...I'm a mainframe and SAS programmer trying to learn UNIX Shell Scripts:<br />I cannot get following command to work properly (it does not concat the records after the START delim...rather it shows last rcrd before the START and it blends last rcrd with leftover from 1st rcrd)...please help; thx:<br /><br />awk '/START/{if (NR!=1)print "";next}{printf $0}END{print "";}' file<br /><br />Al Diovanni<br />adiovanni@earthlink.net<br />C#: 347.525.2501<br />H#: 718.987.8672Anonymoushttps://www.blogger.com/profile/06131903907203885364noreply@blogger.com