The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Recover data from 2 files then combine saint65 UNIX for Dummies Questions & Answers 1 04-19-2008 03:45 PM
how to delete text from line starting pattern1 up to line before pattern2? repudi8or Shell Programming and Scripting 5 04-15-2008 10:25 PM
how to delete line with matching text and line immediately after orahi001 UNIX for Dummies Questions & Answers 6 01-15-2008 12:34 AM
Combine output on same line theninja Shell Programming and Scripting 3 01-14-2008 04:21 AM
Combine reports and append a line between each ldevito1 Shell Programming and Scripting 2 11-08-2006 12:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-02-2008
rcky_mntere rcky_mntere is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
How to combine text data into one line?

The following input needs to be manipulated as follows:

INPUT from file or results of command:
============start:
Medium identifier : a45c0213:47eb5485:0aec:0321
Medium label : SQL Disk_11516
Location : [Windows_System_Library: /backup_09/a45c0213547eb4d2750aec50315.fd]
Protected : None
Medium identifier : a45c0213:47f09a86:0bbb:00d5
Medium label : SQL Disk_11582
Location : [Windows_System_Library: /backup_02/a45c0213547f08c5250bbb500ce.fd]
Protected : None
Medium identifier : a45c0213:47ecac55:0aec:040a
Medium label : SQL Disk_11536
Location : [Windows_System_Library: /backup_02/a45c0213547ecac5550aec50408.fd]
Protected : None
Medium identifier : a45c0213:47f5e816:0b15:01bc
Medium label : SQL Disk_11609
Location : [Windows_System_Library: /backup_09/a45c0213547f5e81650b15501ba.fd]
Protected : 05/04/08 04:55:56
Medium identifier : a45c0213:47fb2681:1e72:0052
Medium label : SQL Disk_11649
Location : [Windows_System_Library: /backup_10/a45c0213547fb268151e725004f.fd]
Protected : 05/08/08 04:50:02
finish====================
Notes: the results are formatted so that the first ":" lines up.

The ========start and finsih======= are not part of the results

Need to process the input so that the results yield:
a45c0213:47fb2681:1e72:0052,SQL Disk_11649,/backup_10/a45c0213547fb268151e725004f.fd,None[orthe date shown next to Protected]

(all on 1 line)

Each record Starts with the Medium identifier line and ends with the Protected line.

Thank you.
  #2 (permalink)  
Old 05-02-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Something along these lines.

nawk -f rcky.awk myInputFile

rcky.awk:

Code:
/^Medium identifier/,/^Protected/ {
  printf("%s%c", substr($0, index($0, ":")+2), ($0 ~ /^Protected/) ? "\n" : ",")
}


Last edited by vgersh99; 05-02-2008 at 02:28 PM.. Reason: anchors
  #3 (permalink)  
Old 05-02-2008
rcky_mntere rcky_mntere is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
Thank you. Works just fine!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0