PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > linux.debian.user > ls and globbing and full pathnames
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
linux.debian.user debian-user@lists.debian.org.

ls and globbing and full pathnames

Réponse
 
LinkBack Outils de la discussion
Vieux 22/01/2007, 23h50   #1
Robert MannI
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut ls and globbing and full pathnames

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

  Réponse avec citation
Vieux 23/01/2007, 00h20   #2
Andrew Sackville-West
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

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-----

  Réponse avec citation
Vieux 29/01/2007, 00h00   #3
x_debian-user_x@nospam.pz.podzone.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

> > 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
  Réponse avec citation
Vieux 29/01/2007, 00h00   #4
x_debian-user_x@nospam.pz.podzone.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

> > 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
  Réponse avec citation
Vieux 29/01/2007, 16h10   #5
Matus UHLAR - fantomas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

> > > 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
  Réponse avec citation
Vieux 29/01/2007, 17h10   #6
x_debian-user_x@nospam.pz.podzone.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

> > 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
  Réponse avec citation
Vieux 29/01/2007, 22h40   #7
Bob McGowan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

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.
>
>


  Réponse avec citation
Vieux 30/01/2007, 10h50   #8
Dan H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

-----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
  Réponse avec citation
Vieux 30/01/2007, 11h50   #9
Jon Dowland
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ls and globbing and full pathnames

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h35.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16361 seconds with 17 queries