Listing files with full path | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Listing files with full path

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-02-2007
r_sethu r_sethu is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 20 January 2010, 9:37 PM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Question Listing files with full path

Hi,

I need to store all the files in a directory to a text file with its full path.
The example below can explain:

./File1.txt
./File2.txt
./Folder1/File11.txt
./Folder1/File12.txt
./Folder1/Folder11/File111.txt
./Folder2/file21.txt
:
:

The ls -R1 command won't give the result as I desired. Please help.

Regards,
Sethu.
Sponsored Links
    #2  
Old 08-02-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Advisor  
Forum Advisor
 
Join Date: Feb 2005
Last Activity: 2 September 2014, 5:08 PM EDT
Location: Foxborough, MA
Posts: 7,644
Thanks: 150
Thanked 577 Times in 542 Posts

Code:
find . -type f | sed "s#^.#$(pwd)#"

Sponsored Links
    #3  
Old 08-02-2007
r_sethu r_sethu is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 20 January 2010, 9:37 PM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Dear vgersh99,

Thanks a lot. It is working fine.

Is it possible to get the files ordered by Last modified date in the same pattern?

Thanks again for all.

Regards,
Sethu.
    #4  
Old 08-02-2007
congo congo is offline
Registered User
 
Join Date: Jun 2006
Last Activity: 25 September 2008, 2:17 PM EDT
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by r_sethu View Post

Is it possible to get the files ordered by Last modified date in the same pattern?

If you can use

Code:
ls -ltR yourpathandpipes

instead of `find` that might make you happy. You can then awk print the filename and append the sed pwd. Or run from another location onto the catalogue where files are placed, then ls should return fullpath.

Do you need hardcode examples ?
Sponsored Links
    #5  
Old 08-02-2007
r_sethu r_sethu is offline
Registered User
 
Join Date: Jul 2007
Last Activity: 20 January 2010, 9:37 PM EST
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Congo,

Thank you. It will be very useful for me if you could give one hardcoded example please.

Regards
Sethu.
Sponsored Links
    #6  
Old 06-15-2009
praving5 praving5 is offline
Registered User
 
Join Date: Mar 2009
Last Activity: 3 August 2009, 5:30 AM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Guys,
I did something good today:

My situation:
-----------

I had 2 servers say server A and server B. Server A had got millions of files and directories. I had to keep the same ownership and group ownership in server B as in Server A. For this I did below:

1. Get to know the file ownerships in server A and put it in a file

find . -type f | sed "s#^.#$(pwd)#" | xargs ls -l | tr -s " " " " | cut -f3,4,9 -d\ > perm.conf

find . -type d | sed "s#^.#$(pwd)#" | xargs ls -ld | tr -s " " " " | cut -f3,4,9 -d\ >> perm.conf

2. copy the perm.conf on the server B under the same hierachy as in server A.

3. Then I wrote a script:

#!/bin/sh

k=`wc -l perm.conf | cut -f1 -d\ `
i=1
RECORD=""
OWNER=""
GROUP=""
FILE=""
while [ $k -ne $i ]
do
RECORD=`head -$i perm.conf | tail -1`
OWNER=`echo $RECORD | cut -f1 -d\ `
GROUP=`echo $RECORD | cut -f2 -d\ `
FILE=`echo $RECORD | cut -f3 -d\ `
chown $OWNER:$GROUP $FILE 2>> logfile
i=`expr $i + 1`
done

and I was done...

Hope this help someone...

Thanks and regards,
Pravin Goyal
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
listing the files without cd to the path raghu.iv85 Shell Programming and Scripting 3 01-31-2011 11:38 PM
How to extract strings from full path when full path is not fixed Shirisha Shell Programming and Scripting 0 10-07-2010 04:08 AM
DOS Dir - listing of full path and timestamp GM_AIX Windows & DOS: Issues & Discussions 5 09-13-2010 12:50 PM
Help with listing given files in a given directory path Amruthesh C Shell Programming and Scripting 3 08-04-2010 11:03 AM
List files with full path mr_bold Shell Programming and Scripting 3 10-07-2008 12:19 PM



All times are GMT -4. The time now is 05:24 PM.