LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-19-2004, 06:31 AM   #1
unholy
Member
 
Registered: Sep 2003
Location: Eire
Distribution: Ubuntu 7.10
Posts: 344

Rep: Reputation: 30
Help a script newbie


Im trying to write a bash script that displays all folders containing ogg or mp3 files. I cannot use locate os the results must be up to date.

l have made 2 different attempts, but dont know how to process fhem further.

Code:
find /music -name '`ogg
This outputs the folders, but they have file names appended.

Code:
find /music -type d
This lists the folders, but some contain no media.

How do I process further?
 
Old 09-19-2004, 07:02 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
What about this:
find /music -name "*.ogg" -exec dirname {} \; | sort -u
 
Old 09-19-2004, 07:05 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
This returns the directories that contain ogg and mp3 files:

$ find /music \( -name "*ogg" -o -name "*mp3" \) -exec dirname {} \; | uniq

I think you need 2 commands to do this: find and uniq. The find command looks for files that end with *ogg or *mp3 and returns all the dirname(s) without the files. The uniq command makes sure you only get unique hits.

There are probably other methods of doing what you want, this came to mind first.

Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script not working need help , i'm newbie aneel_in Programming 5 06-14-2005 04:00 AM
Shell script newbie needs help! allididntwantto Programming 2 04-21-2005 05:53 AM
Newbie ---> use of script howto whschimmel Linux - Games 3 02-27-2005 01:18 AM
Help a newbie write a script! Braveheart1980 Linux - Software 14 09-22-2004 06:40 AM
little newbie script problem uncle_fungus1 Linux - Software 4 01-20-2004 05:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration