[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Bash Scripting Question



On Sat, 2005-04-09 at 01:17 -0400, Hal Vaughan wrote:
> I could swear I remember doing this in the past, but I can't remember how, and 
> I hope it wasn't through a recursive script.
> 
> I've gone through the man and info pages on ls, but I can't find anything 
> (unless I missed the obvious, which has been known to happen before) to use 
> to show a way to print out the full path name for EACH file or directory in a 
> recursive listing?

Obligatory Python Script   ;)

Unordered list of files:

import sys, os, os.path
for root, dirs, files in os.walk(sys.argv[1]):
    for name in files: print os.path.join(root, name)


Ordered list of files:

import sys, os, os.path
lof = []
for root, dirs, files in os.walk(sys.argv[1]):
    for name in files: lof.append(os.path.join(root, name))
lof.sort()
for f in lof: print f

-- 
-----------------------------------------------------------------
Ron Johnson, Jr.
Jefferson, LA USA
PGP Key ID 8834C06B I prefer encrypted mail.

"The irony is that Bill Gates claims to be making a stable
operating system and Linus Torvalds claims to be trying to take
over the world."
seen on the net

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: