Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Getting directory out of find results[SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
PietdeBoer
Apprentice
Apprentice


Joined: 20 Oct 2005
Posts: 244
Location: Eindhoven, the Netherlands

PostPosted: Wed Oct 22, 2008 2:34 pm    Post subject: Getting directory out of find results[SOLVED] Reply with quote

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
View user's profile Send private message
Arfrever
Bodhisattva
Bodhisattva


Joined: 29 Apr 2006
Posts: 2463
Location: 異世界

PostPosted: Wed Oct 22, 2008 2:39 pm    Post subject: Reply with quote

Code:
for x in $(find /data -iname '*.cab') ; do dirname $x ; done
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9523
Location: beyond the rim

PostPosted: Wed Oct 22, 2008 5:48 pm    Post subject: Reply with quote

Or use the -printf option of find to just display the directory part (see the manpage).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum