The UNIX and Linux Forums  

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
How to add new paths to $PATH wrapster SUN Solaris 2 06-01-2008 01:46 AM
Spoofing paths. fahadsadah UNIX for Advanced & Expert Users 3 12-26-2007 04:57 AM
Multiple Paths to SAN with LVM in Linux? deckard Filesystems, Disks and Memory 3 08-10-2007 07:13 AM
Paths update phpote UNIX for Dummies Questions & Answers 5 07-25-2001 04:57 AM
paths caiohn UNIX for Dummies Questions & Answers 1 01-17-2001 03:35 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-06-2007
Registered User
 

Join Date: Aug 2007
Posts: 7
Stumble this Post!
Thumbs up create paths

Hello!

If I have file like that:

AAA
->bbb
->ccc
->ddd
->eee

how to create full paths like:

AAA->bbb
AAA->ccc->ddd
AAA->ccc->eee

?
(I'm sorry for mistakes - english is not my native language)
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-06-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,841
Stumble this Post!
Do you want to list files in a directory tree with a full path name?
Here is an example for a directory called "dir"
Code:
prefix="/dir"
find $prefix -type f |\
while read file 
do
       printf "%s/%s\n" "$prefix" "$file"
done > listfile
Reply With Quote
  #3 (permalink)  
Old 08-06-2007
Registered User
 

Join Date: Aug 2007
Posts: 7
Stumble this Post!
Thank you, but it is not what I wanted...
It is all about text files - I have one, that looks like:

Sistēma
->Pieslēgties
->Datu apmaiņa
-> Kases aparāti
-> Fiskālo printeru serviss
-> Grāmatojumu imports
-> Datu imports
-> Pavadzīmju eksports
-> BarMan imports
-> Datu ārējais eksports
-> Drošības kopija

and I need:

Sistēma->Pieslēgties
Sistēma->Datu apmaiņa-> Kases aparāti
Sistēma->Datu apmaiņa-> Fiskālo printeru serviss

in other text file....
is it possible?
Thanks anyway
Reply With Quote
  #4 (permalink)  
Old 08-06-2007
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,841
Stumble this Post!
Input file
Code:
Sistema
->Pieslegties
->Datu apmaina
-> Kases aparati
-> Fiskalo printeru serviss
-> Gramatojumu imports
-> Datu imports
-> Pavadzimju eksports
-> BarMan imports
-> Datu arejais eksports
-> Drošibas kopija
AddonForTest
->Datu apmaina
-> Kases aparati
-> Fiskalo printeru serviss
-> Gramatojumu imports
-> Datu imports
-> Pavadzimju eksports
-> BarMan imports
Code:
awk '{
     if(index($0, "->")>0) { 
         print base $0}
     else{
         base=$0
     }    
     }' filename
output:
Code:
     
Sistema->Pieslegties
Sistema->Datu apmaina
Sistema-> Kases aparati
Sistema-> Fiskalo printeru serviss
Sistema-> Gramatojumu imports
Sistema-> Datu imports
Sistema-> Pavadzimju eksports
Sistema-> BarMan imports
Sistema-> Datu arejais eksports
Sistema-> Drošibas kopija
AddonForTest->Datu apmaina
AddonForTest-> Kases aparati
AddonForTest-> Fiskalo printeru serviss
AddonForTest-> Gramatojumu imports
AddonForTest-> Datu imports
AddonForTest-> Pavadzimju eksports
AddonForTest-> BarMan imports
Reply With Quote
  #5 (permalink)  
Old 08-07-2007
Registered User
 

Join Date: Aug 2007
Posts: 7
Stumble this Post!
Thank you - it was very useful! So, now I have one level, but there was 2 of them... Is it possible to use regex in index function? For example, how to find Aaaa->Bbbbb and insert it before 3rd level?

Ideas like:
awk 'if (index ($0, "[A-Za-z+->A-Za-z+]")>0) {print base $0} else {base = $0}} ' filename
does not work...

or maybe it is not necesarry to use regexes...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0