|
|
|
|
||||||
| linux.debian.user debian-user@lists.debian.org. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello Linux Masters!
I have a particular problem I need to solve related to the "ls" command and globbing. As an example, to see the all of the files in the root directories of my websites I do: $ ls -m /var/www/* This gives me the output in the form: --- /var/www/site1: index.html, some_image.jpg /var/www/site2: index.html, some_other_file --- Which is beautiful, but I need to work with the output, hence I need the full filepaths, something like this: --- /var/www/site1/index.html, /var/www/site1/some_image.jpg, /var/www/site2/index.html, /var/www/site2/some_other_file --- Is there any known way to get that kind of output instead? Muchas Gracias (Thanks), Rob |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Tue, Jan 23, 2007 at 12:45:33AM +0100, Robert MannI wrote:
> Hello Linux Masters! > > I have a particular problem I need to solve related to the "ls" command > and > globbing. > > As an example, to see the all of the files in the root directories of my > websites I do: > $ ls -m /var/www/* > > This gives me the output in the form: > --- > /var/www/site1: > index.html, some_image.jpg > > /var/www/site2: > index.html, some_other_file > --- > > Which is beautiful, but I need to work with the output, hence I need the > full filepaths, something like this: > --- > /var/www/site1/index.html, /var/www/site1/some_image.jpg, > /var/www/site2/index.html, /var/www/site2/some_other_file > --- > Is there any known way to get that kind of output instead? find /var/www then you get the full joy of using find's many features too. just remember if you are using globbing in find's arguments (such as -name or -iname) that you should escape the wildcards ala \* if you really want a comma seperated list, the check out sed or cut. hth A -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFFtVO5aIeIEqwil4YRAoqyAJ97wx5kI5uhD5O1za2u45 gdXkcVXACgitSc 8Ur9CmPpf65k9sBzpdWsnqI= =/qYe -----END PGP SIGNATURE----- |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
> > I need the
> > full filepaths, something like this: > > --- > > /var/www/site1/index.html, /var/www/site1/some_image.jpg, > > /var/www/site2/index.html, /var/www/site2/some_other_file > > --- > > Is there any known way to get that kind of output instead? > > find /var/www > > then you get the full joy of using find's many features too. And certainly some of those options are needed to print just "all of the files in the root directories... " find /var/www/* -follow -maxdepth 1 -type f > if you really want a comma seperated list, the check out sed or cut. Maybe this would suffice (note it prints directories as well): ls -dm /var/www/*/* -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
> > I need the
> > full filepaths, something like this: > > --- > > /var/www/site1/index.html, /var/www/site1/some_image.jpg, > > /var/www/site2/index.html, /var/www/site2/some_other_file > > --- > > Is there any known way to get that kind of output instead? > > find /var/www > > then you get the full joy of using find's many features too. And certainly some of those options are needed to print just "all of the files in the root directories... " find /var/www/* -follow -maxdepth 1 -type f > if you really want a comma seperated list, the check out sed or cut. Maybe this would suffice (note it prints directories as well): ls -dm /var/www/*/* -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
> > > I need the
> > > full filepaths, something like this: > > > --- > > > /var/www/site1/index.html, /var/www/site1/some_image.jpg, > > > /var/www/site2/index.html, /var/www/site2/some_other_file > > > --- > > > Is there any known way to get that kind of output instead? > > > > find /var/www > > > > then you get the full joy of using find's many features too. On 28.01.07 23:53, x_debian-user_x@nospam.pz.podzone.net wrote: > And certainly some of those options are needed to print just "all of > the files in the root directories... " > > find /var/www/* -follow -maxdepth 1 -type f this will not work, except you only have one non-dot entry in /var/www - the first argument can only be one directory, where /var/www/* will be expanded to list of all files/directories (except those beginning with a dot) in /var/www. > > if you really want a comma seperated list, the check out sed or cut. > > Maybe this would suffice (note it prints directories as well): > > ls -dm /var/www/*/* yes, this might work -- Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/ Warning: I wish NOT to receive e-mail advertising to this address. Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu. LSD will make your ECS screen display 16.7 million colors -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
> > find /var/www/* -follow -maxdepth 1 -type f
> > this will not work, except you only have one non-dot entry in /var/www - the > first argument can only be one directory, where /var/www/* will be expanded > to list of all files/directories (except those beginning with a dot) in > /var/www. Ummm, it works for me... ;-) Using GNU 'find' as supplied with Debian. > > > > if you really want a comma seperated list, the check out sed or cut. > > > > Maybe this would suffice (note it prints directories as well): > > > > ls -dm /var/www/*/* > > yes, this might work Indeed it does too. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
x_debian-user_x@nospam.pz.podzone.net wrote:
>>> find /var/www/* -follow -maxdepth 1 -type f >> this will not work, except you only have one non-dot entry in /var/www - the >> first argument can only be one directory, where /var/www/* will be expanded >> to list of all files/directories (except those beginning with a dot) in >> /var/www. > > Ummm, it works for me... ;-) Using GNU 'find' as supplied with Debian. As it does, as well, on Solaris (the only other *nix OS available to me at the moment). From the Solaris man page, the synopsis says: SYNOPSIS /usr/bin/find path... expression /usr/xpg4/bin/find path... expression Note the ellipses (...) after the 'path' in each. As well, there are no restrictions as to whether path is a directory or a filename, either. The primary issue with the form the original poster used (and it may not be an issue, either, but intentional) is that the wildcard path will automatically *exclude* any and all files/directories whose names begin with a dot, such as .kde or .tkman, for example. Whether this is a problem or a feature depends on exactly what the OP is trying to do. Bob > >>>> if you really want a comma seperated list, the check out sed or cut. >>> Maybe this would suffice (note it prints directories as well): >>> >>> ls -dm /var/www/*/* >> yes, this might work > > Indeed it does too. > > |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Andrew Sackville-West wrote: > if you really want a comma seperated list, the check out sed or cut. or find's -printf option. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFvyE8GdM4FB223AcRApyhAJ968ETTUzJUac+SKmKXD5 H0REd7wgCeKGqa o+meVLDU+zl3FX9UtmNhoW8= =hrs+ -----END PGP SIGNATURE----- -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
On Mon, Jan 29, 2007 at 02:26:46PM -0800, Bob McGowan wrote:
> The primary issue with the form the original poster used > (and it may not be an issue, either, but intentional) is > that the wildcard path will automatically *exclude* any > and all files/directories whose names begin with a dot, > such as .kde or .tkman, for example. > > Whether this is a problem or a feature depends on exactly > what the OP is trying to do. It'll also fail if the glob expands to too many arguments. Generally if you're using find, its to get around limitations with argv lengths, ls output, coping with spaces/odd chars in names, etc., so avoiding a glob in the find call is probably worth it. -- Jon Dowland -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
![]() |
| Outils de la discussion | |
|
|