LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-07-2011, 07:17 AM   #16
Linux_Kidd
Member
 
Registered: Jan 2006
Location: USA
Posts: 737

Original Poster
Rep: Reputation: 78

Quote:
Originally Posted by Nominal Animal View Post
This should do the job, and also split each fact on a separate line. It does a bit more than you asked for, but I guess this is what I'd start with.
Code:
tr -s '\r\n' '\n\n' < infile | sed -e 's|[\t\v\f ]*=[\t\v\f ]*|=|g; s|[\t\v\f ][\t\v\f ]\+\([^\t\v\f =]\+\([\t\v\f ][^\t\v\f =]\+\)*=\)|\n\1|g' | sed -e 's|^[\t\v\f ]\+||; s|[\t\v\f ]\+$||; s|[\t\v\f ]\+)|)|g; s|[\t\v\f ][\t\v\f ]\+| |g' | awk '/^ID=/ { id=$0 ; print id ; next } /=/ && length(id) { print id "|" $0 }' >outfile
i ran this on my real file and got a zero byte output file, so there must be something in real file that causes no output. i ran this on the sample i provided (post #13) and it did have output, but not in the format needed (post #13).

and to remove whitespace around the "=" sign i use
Code:
sed 's/[[:space:]]*=[[:space:]]*/=/g'

Last edited by Linux_Kidd; 11-07-2011 at 10:03 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse file from remote server to caculate count of string existence in that file saurabhmehan Linux - Newbie 2 08-30-2010 12:30 AM
Cannot Rewrite Password File Error Message rduckworth Linux - Server 2 02-28-2007 07:40 AM
groupadd: cannot rewrite group file superluser Linux - Security 4 09-25-2006 06:24 PM
How to rewrite a VIMed file? backpacker Linux - Software 9 06-17-2006 04:24 PM
The mozilla lock file. Stopping its rewrite.. Nichole_knc Slackware 2 05-18-2004 10:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration