Home Man
Search
Today's Posts
Register

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

Tags
awk, shell scripts, solved

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 04-19-2018
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
# 2  
Old 04-19-2018
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)
# 3  
Old 04-20-2018
Quote:
Originally Posted by rdrtx1
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 04-20-2018
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)
# 5  
Old 04-20-2018
Quote:
Originally Posted by RudiC
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
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk script to append suffix to column when column has duplicated values as7951 Shell Programming and Scripting 1 05-09-2018 04:41 AM
Shell script to get one column value(s) nvkuriseti UNIX for Advanced & Expert Users 4 02-23-2016 11:49 AM
awk script to call another script based on second column entry my_Perl Shell Programming and Scripting 1 02-08-2016 09:17 AM
Filter on one column and then perform conditional calculations on another column with a Linux script Zooma Shell Programming and Scripting 12 04-06-2015 10:36 AM
Difference of the same column when two other column matches and one column differs less than 1 hour Lakshmikumari Shell Programming and Scripting 1 05-07-2013 03:16 PM
AWK script to create max value of 3rd column, grouping by first column ckmehta Shell Programming and Scripting 3 06-13-2012 07:34 AM
Change file content 4 column to one Column using script thepurple Shell Programming and Scripting 5 03-03-2012 05:06 AM
Column Script jgrosecl Shell Programming and Scripting 2 06-29-2011 11:33 AM
Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 rydz00 Shell Programming and Scripting 7 11-09-2010 10:28 AM
Changing one column of delimited file column to fixed width column manneni prakash Shell Programming and Scripting 5 06-22-2009 05:27 AM


All times are GMT -4. The time now is 08:53 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password