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 > comp.unix.shell > about find+xargs
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

about find+xargs

Réponse
 
LinkBack Outils de la discussion
Vieux 05/12/2006, 15h24   #1
key9
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut about find+xargs

Hi All

This is just a study note of 'inode'


$ ls -li
....
1926029 drwxrwxr-x 3 key9 key9 4096 2006-11-30 14:53 Gnu Utils
....

$ find . -inum 1926029 -print
../Gnu Utils
$ find . -inum 1926029 -print | xargs ls -l
ls: ./Gnu: No such file or directory
ls: Utils: No such file or directory


So 'find' send the dictionary name but it seems xargs treated it as
separated.
any ideas?
I don't means using -exec 'ls -l' {} \;


youe key9


  Réponse avec citation
Vieux 05/12/2006, 15h40   #2
mobidyc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about find+xargs

"key9" <iamkey9@126.com> a écrit dans le message de
news:el42uh$3pj$1@news.yaako.com...
> Hi All
>
> This is just a study note of 'inode'
>
>
> $ ls -li
> ...
> 1926029 drwxrwxr-x 3 key9 key9 4096 2006-11-30 14:53 Gnu Utils
> ...
>
> $ find . -inum 1926029 -print
> ./Gnu Utils
> $ find . -inum 1926029 -print | xargs ls -l
> ls: ./Gnu: No such file or directory
> ls: Utils: No such file or directory
>
>
> So 'find' send the dictionary name but it seems xargs treated it as
> separated.
> any ideas?
> I don't means using -exec 'ls -l' {} \;
>
>
> youe key9


Hello,

two options:
modify the IFS (space by default), see man your_shell
or
use a while loop:

find . -inum 1926029 -print |while read LINE ;do ls -l $LINE ;done

hope this you.

Regards,
Mobidyc


  Réponse avec citation
Vieux 05/12/2006, 16h02   #3
key9
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about find+xargs



> find . -inum 1926029 -print |while read LINE ;do ls -l $LINE ;done


thank you and this works, buy have to add '"':

$ find . -inum 1926029 -print |while read LINE ;do ls -l "$LINE" ;done

and what I want to know is can I using way like this to xargs?

maybe something like :

(it will NOT WORK!!)
$echo "'find . -inum 1926029 -print '" | xargs ls -l

the idea is 'find' send the resoult to some tools and the tools give out
resoult which xargs can understand


  Réponse avec citation
Vieux 05/12/2006, 16h17   #4
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about find+xargs

2006-12-5, 16:40(+01), mobidyc:
[...]
>> $ find . -inum 1926029 -print
>> ./Gnu Utils
>> $ find . -inum 1926029 -print | xargs ls -l
>> ls: ./Gnu: No such file or directory
>> ls: Utils: No such file or directory
>>

[...]
> modify the IFS (space by default), see man your_shell
> or
> use a while loop:


IFS has no impact on xargs and that variable shouldn't be in the
environment.

> find . -inum 1926029 -print |while read LINE ;do ls -l $LINE ;done


However, it has an impact on "read" and on variable expansions
when not quoted.

find . -inum 1926029 -print |
while IFS= read -r LINE; do
ls -ld -- "$LINE"
done

(which doesn't work for multiline file names).

In order to pipe find to xargs, you need to post-process the
output of find so that it is compatible with the input format
expected by xargs (by default, they are not compatible unless
you use the GNU/BSD specific -print0|xargs -r0)

One way to do it is:

find .//. -inum 1926029 -print |
sed 's/./\\&/g' | awk '
{
if (NR > 1) {
printf "%s", line
if ($0 !~ /\\\/\\\//) printf "\\"
print ""
}
line = $0
}
END { print line }'

--
Stéphane
  Réponse avec citation
Vieux 05/12/2006, 17h00   #5
Glenn Jackman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about find+xargs

At 2006-12-05 10:24AM, "key9" wrote:
> Hi All
>
> This is just a study note of 'inode'
>
>
> $ ls -li
> ...
> 1926029 drwxrwxr-x 3 key9 key9 4096 2006-11-30 14:53 Gnu Utils
> ...
>
> $ find . -inum 1926029 -print
> ./Gnu Utils
> $ find . -inum 1926029 -print | xargs ls -l
> ls: ./Gnu: No such file or directory
> ls: Utils: No such file or directory



Either
find . -inum 1926029 -print0 | xargs -0 ls -l
or
find . -inum 1926029 | xargs -i ls -l {}

--
Glenn Jackman
Ulterior Designer
  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 02h54.


É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,10903 seconds with 13 queries