| johngnub 2007-08-21, 7:24 pm |
| On Aug 21, 3:25 pm, James Michael Fultz <xy...@sent.as.invalid> wrote:
> * Chris Allen <ca.al...@gmail.com>:> How do I find file "findme" in tree "bigtree" searching only
>
> [ ... ]
>
> $ find bigtree -print
> bigtree
> bigtree/not_here
> bigtree/not_here/findme
> bigtree/in_here
> bigtree/in_here/findme
> bigtree/findme
>
> $ find bigtree -wholename '*/in_here/*' -name findme -print
> bigtree/in_here/findme
>
> --
> James Michael Fultz <xy...@sent.as.invalid>
> Remove this part when replying ^^^^^^^^
A few idea, less direct, but may work for you in this case,
Given:
find . |head -5
..
../Foo
../Foo/3file
../Foo/4file
../Foo/5file
Then using cut with a delimit, pls use single quotes, Chop it up, the
last "-" reads as from this field to the last,
find . |cut -d '/' -f2 |head -5
..
Foo
Foo
Foo
Foo
Or
find . |cut -d '/' -f3 |head -5
..
3file
4file
5file
Or, try the shell regex ops, these are not a nice to use, but can be
very powerful, I do find cut easier to use for me,
Set up a var,
foo=`find .|head -5`
Then loop over the var, try the shell regex on the var, try then for
fun,
syntax = ${var##/*} or ${var#/*}, or ${var%/*} or ${var%%/*},
for x in $foo; do echo "${x##*/}"; done
..
Foo
3file
4file
5file
2 cents, JB
|