Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to find settings.xml file in my Ubuntu machine. I have no clue where it is, and which directory it is in.

I tried using this -

ls -R | grep settings.xml

But it doesn't show me the full path where it is.. Is there any other command which I need to try that can give me the full path?

share|improve this question
2  
Whenever you think the solution is to parse the output of ls, you are almost certainly doing it the wrong way. –  terdon Feb 11 at 0:38

4 Answers 4

up vote 7 down vote accepted

For fast search (but not definitive):

locate -br ^settings.xml$

From man locate:

   locate  reads  one or more databases prepared by updatedb(8) and writes
   file names matching at least one of the PATTERNs  to  standard  output,
   one per line.

   -b, --basename
          Match  only  the base name against the specified patterns.  This
          is the opposite of --wholename.
   -r, --regexp REGEXP
          Search for a basic regexp REGEXP.  No PATTERNs  are  allowed  if
          this  option  is used, but this option can be specified multiple
          times.

The ^ and $ ensure that only files whose name is settings.xml and not files whose names contain settings.xml will be printed.

You may need for the first time to run: updatedb (as root) to update/build the database of locate.

share|improve this answer
    
@terdon, you surprised me, I have never though about looking to man locate before!!! assuming it just simple search tool. Thank you very much. –  Sneetsher Feb 11 at 0:46
    
Yes, that was pretty much my reaction the first time I read the man page :) –  terdon Feb 11 at 0:47
3  
it is worth noting the role of updatedb for this command -- locate often fails without that, for me, anyways –  rm-vanda Feb 11 at 0:55
    
@rm-vanda, I've updated the answer to mention updatedb. Thank you. –  Sneetsher Feb 11 at 1:07

A slow but steady search through file-system, but Definitive.

find / -xdev -name settings.xml

It will take some time and you may get some permission errors but it will get there. If you've got some more idea where it may be located change the first directory from / to /where/you/guess

share|improve this answer
    
Appending 2>/dev/null to the end of the command will suppress all of the error output (by redirecting stderr to the null device). –  Tanner Swett Feb 12 at 18:43

tree is another good way, if you aren't sure exactly what you're looking for, and it seems to be a bit faster- :

tree -f / | grep settings.xml

Other useful flags: -i on grep will ignore the case, -h for human readable on tree --

-- the man page has a lot of useful options -!

share|improve this answer
3  
Not a good idea, tree(1) shows an ASCII-art tree of the files, which is then mutilated by grep(1). –  vonbrand Feb 11 at 1:24
1  
Yes, if you're going to use tree, you may as well use find . type -f which will be faster. –  terdon Feb 11 at 1:29
    
OK, good tip -! –  rm-vanda Feb 11 at 3:49

Example:

$ locate settings.xml
/usr/share/mime/application/x-cisco-vpn-settings.xml
share|improve this answer
    
Upgrade, Fedora 18 is end-of-life. –  vonbrand Feb 11 at 1:22
1  
It works. That's all that matters. –  octopusb Feb 11 at 1:57
    
Until you get pwnd, or you want to install some new piece of software. –  vonbrand Feb 11 at 2:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.