The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
text manipulation injeti Shell Programming and Scripting 11 06-05-2008 10:42 AM
Text file manipulation Ezy UNIX for Dummies Questions & Answers 4 02-25-2008 01:15 PM
Text Manipulation. Icepick Shell Programming and Scripting 4 02-25-2008 04:18 AM
Text file manipulation svannala UNIX for Dummies Questions & Answers 5 01-20-2006 07:01 PM
shell script : text manipulation (easy quesiton) champion Shell Programming and Scripting 3 07-01-2002 03:10 AM

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 Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 06-23-2008
rajkishore rajkishore is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
Post text manipulation

I am tryin to figure out how to extract interested text from file

example.txt

blah blah
blah a: child1
blah a: child2
blah b: parent1
blah blah
blah ....
blah a: child21
blah a: child22
blah a: child23
blah b: parent2


this kinda text repeats .. number of children is not fixed they vary randomly..

the goal is to end up with a file whihc has all the children names under the related parent name.
  #2 (permalink)  
Old 06-24-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
for this example, what output are you expecting?
  #3 (permalink)  
Old 06-24-2008
rajkishore rajkishore is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
Arrow Expected output

Expected output:

In a text file:

Parent1
child1
child2

parent2
child21
child22
child23

parent3

child31
child32
....

***************************************

In the file 'a' and 'b' are the identifiers for the parent and children.

Thanks to you.

I thought of doing something like:

step 1: Grep for parents and then after I get the list of parents {may be in an array}

step 2: I can grep for children with a condition which checks if I hit the first parent from the previously obtained list. When I hit the first parent then save the child list to a text file with the parent name on it.

step 3: Again proceed for the next ones by keeping every thing in a for loop and update the text file every time.


If this algorithm sounds good then the point I am stuck with is step 2.

can you help me out there/ or with any other alternative way.
  #4 (permalink)  
Old 06-24-2008
rajkishore rajkishore is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
May be a regexpression

May be a regexpression can do it easily.

A command like:

grep expression textfile.txt | tee newfile.txt

where expresion will say list me all lines which has 'a:' or 'b:' in it and now the newfile.txt will have all my interested lines.

with the parent names below their child names
{I some how have to get rid of the extra text like blah blah }

Can you point me how the regexpression should be like
  #5 (permalink)  
Old 06-24-2008
rajkishore rajkishore is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 4
This can do It

grep [ab] [:] textfile.txt | tac | cut -d":" f2 | tee result.txt


Thanks Yogesh and other who viewed/etc my post .

Cheers,
Raj
  #6 (permalink)  
Old 03-06-2009
haris haris is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 25
is there any command to convert

figure to text

for eg: 05032009 to 5March2009
  #7 (permalink)  
Old 03-06-2009
ripat ripat is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2006
Location: Belgium
Posts: 438
@ haris this is the third time you post the very same question on someone else's post. I have replied to your problem here:
Parsing log files, displaying logs between specific dates
Closed Thread

Bookmarks

Tags
cut, grep

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 07:44 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