Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List containing directory?

Status
Not open for further replies.

stackdump

Technical User
Sep 21, 2004
278
GB

I have a database where each product has a directory, beneath that are the various versions. e.g.

product1
product1/a.b.c
product1/a.b.d
product2
product3
product3/n.m.o
product4 etc.

Some products have no versions.

I want to list all products that have versions available, so ls -1d mydatabase/*/*.*.* works but gives me all matches. I want to reduce this list to show just the containing folders;

e.g.
product1 product3 etc.

ls -1 mydatabase/*/*.*.*/.. doesnt work.

Any ideas?
 
You may try something like this:
ls -1d mydatabase/*/*.*.* | awk -F/ '{print $2}' | sort -u

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Try...
[tt] ls -1d mydatabase/*/*.*.* | grep / | cut -d / -f1 | uniq[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top