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

Re: [Newbie] Can ls command format output my way?



On 2016-12-17 at 10:40, Richard Owlett wrote:

> ls -R /media/data produces the content but not the NEEDED format.
> 
> I want a list like:
> /media/data/dir1/filea
> /media/data/dir1/fileb
> /media/data/dir1/subdir1/filex
> /media/data/dir1/subdir1/filey
> /media/data/dir1/subdir1/filez
> /media/data/dir2/filea
> /media/data/dir2/fileb
> /media/data/dir2/subdir1/filex
> /media/data/dir2/subdir1/filey
> /media/data/dir2/subdir1/filez
> et cetera
> 
> I don't wish anything but full path to all files in a top level 
> directory.
> 
> Followup question how should I found the answer for myself. I 
> looks basic enough ...

I can't say for sure that ls can't do this, but if I wanted that, I'd
use find.

'find /path/to/directory' produces a list of all nodes (files,
directories, or otherwise) in the specified directory, in exactly the
format you indicate.

Generally, if you want to do something recursively across directories in
an *nix environment, find is the tool to use. Some tools do have
recursiveness options of their own, and occasionally those options are
easier to use or provide better functionality, but in most cases you're
better off going to find as a first resort.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: