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
Listing files with full path r_sethu UNIX for Dummies Questions & Answers 5 06-15-2009 03:56 AM
List files with full path mr_bold Shell Programming and Scripting 3 10-07-2008 01:19 PM
find & copy files with absolute path jagnikam Shell Programming and Scripting 15 05-15-2008 07:00 PM
list all files with full path of the file Sowser UNIX for Advanced & Expert Users 4 02-13-2007 05:46 PM
Removing duplicate files from list with different path vino Shell Programming and Scripting 10 05-12-2005 09:44 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 Rate Thread Display Modes
  #1 (permalink)  
Old 01-08-2008
zdn3023 zdn3023 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 5
how to cat files with path? Help plz

Hi,
I am trying to organize my data files and I would like to know how to cat files with path. Note that the correct command may not be "cat" though.
For example, I have:
abc/data/1/title
dca/data/2/title
gpd/data/1/title
....

I'd like to have a file listing the title info from different directories, as well as directory paths.

Thanks

Simon
  #2 (permalink)  
Old 01-08-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
Question

How should the o/p look like
  #3 (permalink)  
Old 01-08-2008
zdn3023 zdn3023 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 5
Quote:
Originally Posted by shamrock View Post
How should the o/p look like

The output should be like:
48/pdata/1/title:ub2k63r, 1mM in PBS buffer, crp, for nemo titration
49/pdata/1/title:ub2k63r nemo titration, 1/5 nemo
50/pdata/1/title:ub2k63r nemo titration, 1/5 nemo
83/pdata/1/title:quick T2_2 of n15-NEMO+k63-Ub2

The text after colon( is the text written in the title file.
Actually I succeeded once before, but I forgot what command(s) I used. I think I used "find", but can't make it work this time.

Thanks,
  #4 (permalink)  
Old 01-08-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Post

Code:
for file in `find /base/path -type f -name "title"` ; do echo "${file}:`head -1 $file`"; done
  #5 (permalink)  
Old 01-08-2008
zdn3023 zdn3023 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 5
Quote:
Originally Posted by Smiling Dragon View Post
Code:
for file in `find /base/path -type f -name "title"` ; do echo "${file}:`head -1 $file`"; done
Hi, Thanks for the suggestion.
However, I am still confused. Could you be more detailed?
Thanks
  #6 (permalink)  
Old 01-08-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Quote:
Originally Posted by zdn3023 View Post
Hi, Thanks for the suggestion.
However, I am still confused. Could you be more detailed?
Thanks
Not sure what you mean... Does the code not work? What error do you get?
  #7 (permalink)  
Old 01-08-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
Quote:
Originally Posted by zdn3023 View Post
Hi,
I am trying to organize my data files and I would like to know how to cat files with path. Note that the correct command may not be "cat" though.
For example, I have:
abc/data/1/title
dca/data/2/title
gpd/data/1/title
....

I'd like to have a file listing the title info from different directories, as well as directory paths.

Thanks

Simon
Code:
find /path/to/files -type f -name "title" -exec nawk 'FNR==1{print FILENAME":"$0}' {} \;
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 12:16 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