LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2011, 01:57 PM   #1
silentray
LQ Newbie
 
Registered: Oct 2006
Location: London
Distribution: Gentoo 2008.0
Posts: 23

Rep: Reputation: 15
Question about a Linux command line tool


Hi

I used to see one of my colleagues uses a very cool command line tool which uses ** to represent any number of folder hierarchy.

For example:
If there is a file MyFile.java somewhere in:
~/devel/project/component/src/server/com/mycompany/MyFile.java

The tool can simply list the file by using:
ls -l **/MyFile.java

Can anyone let me know what this tool is?

Many thanks
Kevin
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-09-2011, 02:05 PM   #2
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
I am not familiar with a tool that uses ** like that - but find would get the job done
Code:
find ~ -name MyFile.java -ls
 
Old 12-09-2011, 02:50 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
It's bash's "globstar" option:

Code:
shopt -s globstar
 
4 members found this post helpful.
Old 12-09-2011, 03:25 PM   #4
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
There's something worth learning

Although I see that like * it only matches non-hidden directories, so ls -l **/session.rdf won't find session.rdf in .mozilla/ (nor will ls -la **/session.rdf).

Last edited by SecretCode; 12-09-2011 at 03:29 PM.
 
Old 12-10-2011, 01:09 PM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
Use shopt -s dotglob to force globs to match hidden files.

Also, whatever globbing pattern follows **/ will be applied to the top-level directory as well as all subdirectories. So you can use **/.[^.]* to list all dotfiles in the tree (with [^.] there to keep it from matching the . and .. directories).
 
4 members found this post helpful.
  


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
looking for modbus TCP to canbus gateway command line tool for linux golden_boy615 Linux - Software 0 05-02-2011 07:31 AM
How to use a command line tool? Advice Pro Linux - Software 1 03-21-2011 04:12 PM
What command line tool in Linux works like WinZip in windows? toastyjsd Linux - Newbie 5 02-18-2009 05:50 PM


All times are GMT -5. The time now is 04:55 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