Re: [Newbie] Can ls command format output my way?
> > This Vortex won't last long enough. it only feels like -40 f where i'm at. > Several of the responses I've received are opening my eyes to > what can be done with some straight forward (if not simple) shell > commands. the beauty of the cli em
Re: [Newbie] Can ls command format output my way?
On 12/17/2016 10:59 AM, David Wright wrote: 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! This Vortex won't last long enough. Several of the responses I've received are opening my eyes to what can be done with some straight forward (if not simple) shell commands.
Re: [Newbie] Can ls command format output my way?
something else that you could use is 'locate' it's on most systems nowdays and it updates each night from cron. it's not as cpu intensive and you can update is quickly with 'updatedb'. if you're just searching removable media, as in your /media/... example then find would be better. i prefer locate to find when searching the entire system. em
THANK YOU [Re: [Newbie] Can ls command format output my way?]
On 12/17/2016 9:40 AM, 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 ... TIA "find" is what I was looking for. Browsing the man page suggests I can even select which lines to print - i.e. I'm only really in files of form *.html . Thanks again.
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.
Re: [Newbie] Can ls command format output my way?
Richard Owlettwrites: > 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. > find /media/data -type f > Followup question how should I found the answer for myself. I looks > basic enough ... > TIA I don't recall now when I first learnt about the find command. Now I use it all the time. The Unix Power Tools book (http://shop.oreilly.com/product/9780596003302.do) has a chapter on the find command. If you have access to an O'Reilly Safari account, you could browse through it. -- regards, kushal
Re: [Newbie] Can ls command format output my way?
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. /Lars
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 signature.asc Description: OpenPGP digital signature
[Newbie] Can ls command format output my way?
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 ... TIA