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.

awk script row to column

Shell Programming and Scripting


Tags
awk, solved

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-19-2018   -   Original Discussion by buncit8
buncit8's Unix or Linux Image
buncit8 buncit8 is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 4 May 2018, 3:47 AM EDT
Posts: 21
Thanks: 12
Thanked 0 Times in 0 Posts
awk script row to column

Hi..

I have data :


Code:
Report testing1 20180419 08:00
Report testing2 20180419 07:35
Report testing 20180419 08:01
Source = data1
Report testing4 20180419 08:05
Source = data1
Report testing5 20180419 08:10
Source = data2
Report testing6 20180419 08:01
Report testing7 20180419 08:19
Report testing8 20180419 08:15
Source = data2

Output will be :


Code:
Report testing1 20180419 08:00
Report testing2 20180419 07:35
Report testing 20180419 08:01 Source = data1
Report testing4 20180419 08:05 Source = data1
Report testing5 20180419 08:10 Source = data2
Report testing6 20180419 08:01
Report testing7 20180419 08:19
Report testing8 20180419 08:15 Source = data2


Need help for the script awk.

Thanks all
Sponsored Links
    #2  
Old Unix and Linux 04-19-2018   -   Original Discussion by buncit8
rdrtx1's Unix or Linux Image
rdrtx1 rdrtx1 is offline Forum Advisor  
Registered Pusher
 
Join Date: Sep 2012
Last Activity: 31 May 2018, 9:41 AM EDT
Location: Houston, Texas, USA
Posts: 1,142
Thanks: 0
Thanked 421 Times in 398 Posts


Code:
awk '
NR > 1 {printf ($0 ~ /^Source/) ? " " : "\n"; }
{printf $0}
END { if ($0 ~ /^Source/) print ""}
' data

The Following User Says Thank You to rdrtx1 For This Useful Post:
buncit8 (04-20-2018)
Sponsored Links
    #3  
Old Unix and Linux 04-20-2018   -   Original Discussion by buncit8
buncit8's Unix or Linux Image
buncit8 buncit8 is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 4 May 2018, 3:47 AM EDT
Posts: 21
Thanks: 12
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by rdrtx1 View Post


Code:
awk '
NR > 1 {printf ($0 ~ /^Source/) ? " " : "\n"; }
{printf $0}
END { if ($0 ~ /^Source/) print ""}
' data
i still didn't get it bro
    #4  
Old Unix and Linux 04-20-2018   -   Original Discussion by buncit8
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 June 2018, 8:24 AM EDT
Location: Aachen, Germany
Posts: 12,917
Thanks: 429
Thanked 3,967 Times in 3,648 Posts
WHAT don't you get? Please be way more eloquent, showing non-satisfying output and error messages. rdrtx1's proposal works for me.
The Following User Says Thank You to RudiC For This Useful Post:
buncit8 (04-20-2018)
Sponsored Links
    #5  
Old Unix and Linux 04-20-2018   -   Original Discussion by buncit8
buncit8's Unix or Linux Image
buncit8 buncit8 is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 4 May 2018, 3:47 AM EDT
Posts: 21
Thanks: 12
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by RudiC View Post
WHAT don't you get? Please be way more eloquent, showing non-satisfying output and error messages. rdrtx1's proposal works for me.
im so sorry my friend.. i just wrong copy paste..
its worked now..

thanks
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
awk to print first row with forth column and last row with fifth column in each file cdfd123 UNIX for Dummies Questions & Answers 4 02-09-2013 06:07 PM
awk - script help: column to row format of data allignment? rveri Shell Programming and Scripting 4 01-12-2013 05:58 AM
append column and row header to a file in awk script. FUTURE_EINSTEIN UNIX for Dummies Questions & Answers 4 08-07-2012 08:20 AM
Subtracting each row from the first row in a single column file using awk ks_reddy Shell Programming and Scripting 11 04-04-2012 03:31 PM
AWK Script - Print a column - within a Row Range panapty Shell Programming and Scripting 6 09-28-2011 08:54 AM



All times are GMT -4. The time now is 10:42 AM.