LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 07: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, 08:02 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

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

Rep: Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392Reputation: 2392
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 05:00 AM
Shell script newbie needs help! allididntwantto Programming 2 04-21-2005 06:53 AM
Newbie ---> use of script howto whschimmel Linux - Games 3 02-27-2005 02:18 AM
Help a newbie write a script! Braveheart1980 Linux - Software 14 09-22-2004 07:40 AM
little newbie script problem uncle_fungus1 Linux - Software 4 01-20-2004 06:48 PM

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

All times are GMT -5. The time now is 10:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration