View previous topic :: View next topic |
Author |
Message |
PietdeBoer Apprentice
Joined: 20 Oct 2005 Posts: 244 Location: Eindhoven, the Netherlands
|
Posted: Wed Oct 22, 2008 2:34 pm Post subject: Getting directory out of find results[SOLVED] |
|
|
Hi all,
I want to get the directory out of a find command in bash.
I do a
Code: | find /data -iname *.cab
|
it results:
Code: | /data/win32/cd1/1.cab |
i want to extract the directory wich 1.cab is in. how can i achieve this? _________________ _ Got Root? _
Last edited by PietdeBoer on Thu Oct 23, 2008 1:07 pm; edited 1 time in total |
|
Back to top |
|
|
Arfrever Bodhisattva
Joined: 29 Apr 2006 Posts: 2463 Location: 異世界
|
Posted: Wed Oct 22, 2008 2:39 pm Post subject: |
|
|
Code: | for x in $(find /data -iname '*.cab') ; do dirname $x ; done |
|
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9523 Location: beyond the rim
|
Posted: Wed Oct 22, 2008 5:48 pm Post subject: |
|
|
Or use the -printf option of find to just display the directory part (see the manpage). |
|
Back to top |
|
|
|