Unix administration - listing directory contents WITH path to files

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > January 2004 > listing directory contents WITH path to files





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author listing directory contents WITH path to files
Rob Baxter

2004-01-23, 5:01 pm

Hi,

I have looked through the arguments for 'dir' and 'ls' on a redhat 8.0
linux system and can't seem to figure out how to generate output that
includes the file and the path to that file. I'm using BASH. I need:

/path/to/file1.txt
/path/to/file2.txt

instead of (ls -1):

file1.txt
file2.txt

Any ideas? Surely this is possible, thanks in advance as always.
Scott McMillan

2004-01-23, 5:01 pm

On 5 Sep 2003 07:29:51 -0700, rbaxter@cyence.com (Rob Baxter) wrote:
quote:

>Hi,
>
>I have looked through the arguments for 'dir' and 'ls' on a redhat 8.0
>linux system and can't seem to figure out how to generate output that
>includes the file and the path to that file. I'm using BASH. I need:
>
>/path/to/file1.txt
>/path/to/file2.txt
>
>instead of (ls -1):
>
>file1.txt
>file2.txt
>
>Any ideas? Surely this is possible, thanks in advance as always.



find ./ -print

man find


Scott McMillan

Barry Margolin

2004-01-23, 5:01 pm

In article <baea5fa.0309050629.21712bd3@posting.google.com>,
Rob Baxter <rbaxter@cyence.com> wrote:
quote:

>Hi,
>
>I have looked through the arguments for 'dir' and 'ls' on a redhat 8.0
>linux system and can't seem to figure out how to generate output that
>includes the file and the path to that file. I'm using BASH. I need:
>
>/path/to/file1.txt
>/path/to/file2.txt
>
>instead of (ls -1):
>
>file1.txt
>file2.txt
>
>Any ideas? Surely this is possible, thanks in advance as always.



ls /path/to/*

If you want to see the dot-files as well:

ls /path/to/.* /path/to/*

--
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Barry Margolin

2004-01-23, 5:01 pm

In article <gx16b.569$mD.505@news.level3.com>,
Barry Margolin <barry.margolin@level3.com> wrote:
quote:

>ls /path/to/*
>
>If you want to see the dot-files as well:
>
>ls /path/to/.* /path/to/*



Oops, you should use the -d option in both of those, to avoid having it
open up subdirectories.

--
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Chris F.A. Johnson

2004-01-23, 5:01 pm

On Fri, 05 Sep 2003 at 14:29 GMT, Rob Baxter wrote:
quote:

> Hi,
>
> I have looked through the arguments for 'dir' and 'ls' on a redhat 8.0
> linux system and can't seem to figure out how to generate output that
> includes the file and the path to that file. I'm using BASH. I need:
>
> /path/to/file1.txt
> /path/to/file2.txt
>
> instead of (ls -1):
>
> file1.txt
> file2.txt
>
> Any ideas? Surely this is possible, thanks in advance as always.



ls -d $PWD/*

For shells which do not maintain the $PWD variable:

ls -d `pwd`/*

--
Chris F.A. Johnson http://cfaj.freeshell.org
========================================
===========================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
Rob Baxter

2004-01-23, 5:01 pm

Barry Margolin <barry.margolin@level3.com> wrote in message news:<2y16b.570$mD.491@news.level3.com>...
quote:

> In article <gx16b.569$mD.505@news.level3.com>,
> Barry Margolin <barry.margolin@level3.com> wrote:
>
> Oops, you should use the -d option in both of those, to avoid having it
> open up subdirectories.



I used the "ls /path/to/*" option to solve the problem - thanks to
everyone. I had actually tried "ls /path/to" but that doesn't work -
you have to add the asterisk...I'd never have thought that. Cheers,

Rob
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com