👤
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, 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
Transpose column to row - awk theflamingmoe Shell Programming and Scripting 3 07-30-2013 08:10 PM
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
awk-gsub on column-wise on each row elamurugu Shell Programming and Scripting 4 12-13-2010 05:09 AM
awk question row into column calitiggr UNIX for Dummies Questions & Answers 2 09-17-2010 12:28 PM
Adding a column with the row number using awk cosmologist UNIX for Dummies Questions & Answers 4 04-26-2010 08:22 PM
Get value of last row and 6 column from awk wakhan Shell Programming and Scripting 4 09-05-2008 03:41 PM


All times are GMT -4. The time now is 09:23 PM.

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





Not a Forum Member?
Forgot Password?