|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
> 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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|