≡ Menu

Finding files in Linux filesystems

Both Linux and Unixish provides command to find file. The best and easy way to find file is to use command called locate. It list files in databases that match a pattern. For example to find file called myprog.c you need to use locate command as follows:

$ locate myprog.c | less

Another option is to use find command. For example find out all C source code file from /home/jerry directory:
$ find /home/jerry -name “*.c” -print
$ find ~jerry -name “*.c” -print
Please note that ~jerry is short-cut name to refer user jerry’s home directory (/home/jerry). FIND command has very advance usage please see following articles for more information:

Share this tutorial on:
{ 5 comments… add one }
  • NickJOctober 5, 2006, 5:31 am

    How do I take a backup of a file which is continuously written by an application. And if the application not able to write in that file it will get crashed. I dont want to crashed the application.
    Also, the file size is around 700MB to 1GB.
    Please advice..

  • nixCraftOctober 5, 2006, 12:13 pm


    USE LVM based backup, see following url for Logical Volume Manager snapshot to avoid inconsistent backup


  • aref ghobadiAugust 23, 2015, 6:01 am

    very nice article

  • tjSeptember 28, 2016, 11:23 am

    This can be improved with a regular expression; like this:
    $ find /home/jerry/ -regex '^.*\.c$'.

  • tjSeptember 28, 2016, 11:27 am

    This can be improved with a regular expression; like so:

    $ find /home/jerry/ -regex '^.*\.c$'


Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: