Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Character screening and paste into new file in columns instead of rows

Shell Programming and Scripting


Tags
awk, print line, unix

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 1 Week Ago
Ankit Vyas Ankit Vyas is offline
Registered User
 
Join Date: Jun 2017
Last Activity: 13 June 2017, 5:46 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Hammer & Screwdriver Character screening and paste into new file in columns instead of rows


Code:
QL10169_SAUJANA%SubNetwork=ONRM_ROOT_MO_R,SubNetwork=ERBS_KCRN11,MeContext=QL10169_SAUJANA_5
%External_Link_Failure
%X2_link_problem_to_one_or_several_neighbouring_eNodeBs.
QL10187_MATANG_JAYA_2%SubNetwork=ONRM_ROOT_MO_R,SubNetwork=ERBS_KUCHING,MeContext=QL10187_MATANG_JAY A_2_3
%External_Link_Failure
%X2_link_problem_to_one_or_several_neighbouring_eNodeBs.
QL10192_JLNKRUKUP%SubNetwork=ONRM_ROOT_MO_R,SubNetwork=ERBS_MRRN13,MeContext=QL10192_JLNKRUKUP_1
%External_Link_Failure
%X2_link_problem_to_one_or_several_neighbouring_eNodeBs.


Above is the example, i want to do something like below,
1.Check first character of everyline if it is not % then print in the new file.
2.Read secondline if it is "%", then it should paste into the 2nd column of the first line which already pasted.
3.like wise till end of the line.


Moderator's Comments:
Character screening and paste into new file in columns instead of rows Please use CODE tags as required by forum rules!

Last edited by RudiC; 1 Week Ago at 04:15 AM.. Reason: Added CODE tags.
Sponsored Links
    #2  
Old Unix and Linux 1 Week Ago
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 24 June 2017, 9:50 AM EDT
Location: Aachen, Germany
Posts: 10,953
Thanks: 277
Thanked 3,367 Times in 3,100 Posts
Like so?

Code:
awk '{printf "%s%s", /^%/?"\t":TRS, $0; TRS = ORS}   END {printf ORS}' file

Sponsored Links
    #3  
Old Unix and Linux 1 Week Ago
Ankit Vyas Ankit Vyas is offline
Registered User
 
Join Date: Jun 2017
Last Activity: 13 June 2017, 5:46 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
attaching codetags


Code:
awk '/~^%/ { print line; line=$1; sep = "\n"; next } { line = line sep $1; sep = "\t" } END { print line }' 2.log


Moderator's Comments:
Character screening and paste into new file in columns instead of rows Please use CODE tags as required by forum rules!

Last edited by RudiC; 1 Week Ago at 04:42 AM.. Reason: Added CODE tags.
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Character screening and paste into newfile in columns instead of rows Ankit Vyas UNIX for Beginners Questions & Answers 2 1 Week Ago 11:38 AM
Deleting all the fields(columns) from a .csv file if all rows in that columns are blanks ks_reddy Shell Programming and Scripting 4 02-04-2013 04:37 AM
Paste second columns from files to its corresponding file shoaibjameel123 Shell Programming and Scripting 1 10-27-2011 11:44 PM
Copy and Paste Columns in a Tab-Limited Text file evelibertine Shell Programming and Scripting 5 05-26-2011 10:01 PM
How to changes rows to columns in a file oracle123 Shell Programming and Scripting 4 07-31-2008 04:38 AM



All times are GMT -4. The time now is 09:51 AM.