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

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



On Sat 17 Dec 2016 at 17:57:26 (+0200), Lars Noodén wrote:
> On 12/17/2016 05:40 PM, Richard Owlett wrote:
> [...]
> > 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 ...
> > TIA
> 
> One way would be to use find combined with realpath.
> 
> 	find /media/data -exec realpath "{}" \;
> 
> That's recursive.  If you want only that one directory, limit how deep
> it may go:
> 
> 	find /media/data -maxdepth 1 -exec realpath "{}" \;
> 
> If that's too long to type out each time, you can make a shell alias or
> function that accepts the path as an option and then passes that to find.

To get the format as the OP displayed it, you may also need to pipe
the output through sort.

But bear in mind that, using realpath, the output could have files
rooted all over the place (eg try with /etc/systemd/), so after
sorting them, files that you thought would appear together may well
get separated.

man find   will make a good long read during the Polar Vortex!

Cheers,
David.


Reply to: