How can I find a file whose name fits a particular pattern using `find`?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
-1
down vote

favorite












I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:



  • file should start with letter g

  • filename should have only 3 characters

  • file extension must be .d

The search should be performed with the command find.










share|improve this question























  • Did you read the find manpage? What is unclear there?
    – PerlDuck
    Mar 18 at 9:11










  • How can I get help on terminal commands?
    – dessert
    Mar 18 at 9:17










  • Unclear how to find with only 3characters, starts with letter "g".
    – Maxim Savchuk
    Mar 18 at 9:20






  • 2




    File or filename should start with g? If filename, does the character limit include the .d extension?
    – muru
    Mar 18 at 10:30














up vote
-1
down vote

favorite












I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:



  • file should start with letter g

  • filename should have only 3 characters

  • file extension must be .d

The search should be performed with the command find.










share|improve this question























  • Did you read the find manpage? What is unclear there?
    – PerlDuck
    Mar 18 at 9:11










  • How can I get help on terminal commands?
    – dessert
    Mar 18 at 9:17










  • Unclear how to find with only 3characters, starts with letter "g".
    – Maxim Savchuk
    Mar 18 at 9:20






  • 2




    File or filename should start with g? If filename, does the character limit include the .d extension?
    – muru
    Mar 18 at 10:30












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:



  • file should start with letter g

  • filename should have only 3 characters

  • file extension must be .d

The search should be performed with the command find.










share|improve this question















I'm learning Ubuntu in University and the task is find a file in the command line with the following instruction:



  • file should start with letter g

  • filename should have only 3 characters

  • file extension must be .d

The search should be performed with the command find.







16.04 command-line find






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 20 at 12:31









Zanna

48.1k13120228




48.1k13120228










asked Mar 18 at 9:09









Maxim Savchuk

11




11











  • Did you read the find manpage? What is unclear there?
    – PerlDuck
    Mar 18 at 9:11










  • How can I get help on terminal commands?
    – dessert
    Mar 18 at 9:17










  • Unclear how to find with only 3characters, starts with letter "g".
    – Maxim Savchuk
    Mar 18 at 9:20






  • 2




    File or filename should start with g? If filename, does the character limit include the .d extension?
    – muru
    Mar 18 at 10:30
















  • Did you read the find manpage? What is unclear there?
    – PerlDuck
    Mar 18 at 9:11










  • How can I get help on terminal commands?
    – dessert
    Mar 18 at 9:17










  • Unclear how to find with only 3characters, starts with letter "g".
    – Maxim Savchuk
    Mar 18 at 9:20






  • 2




    File or filename should start with g? If filename, does the character limit include the .d extension?
    – muru
    Mar 18 at 10:30















Did you read the find manpage? What is unclear there?
– PerlDuck
Mar 18 at 9:11




Did you read the find manpage? What is unclear there?
– PerlDuck
Mar 18 at 9:11












How can I get help on terminal commands?
– dessert
Mar 18 at 9:17




How can I get help on terminal commands?
– dessert
Mar 18 at 9:17












Unclear how to find with only 3characters, starts with letter "g".
– Maxim Savchuk
Mar 18 at 9:20




Unclear how to find with only 3characters, starts with letter "g".
– Maxim Savchuk
Mar 18 at 9:20




2




2




File or filename should start with g? If filename, does the character limit include the .d extension?
– muru
Mar 18 at 10:30




File or filename should start with g? If filename, does the character limit include the .d extension?
– muru
Mar 18 at 10:30










1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










Since you are allowed to use the find command, this is quite simple:



find / -type f -name "g??.d"


This will find all files (-type f) with a name that starts
with g, followed by two arbitrary characters ??, followed
by .d (-name "g??.d") in the root directory / and below.



When run as non-root user you will get many permission denied
errors because not all directories below / are accessible
by non-root. Also, it may take a while.



Change / to the path where you want to start the search from,
e.g. /home/your_user or simply . for the current directory.



Add -ls to get not only the file's names but also their attributes
(size, age, permissions):



find . -type f -name "g??.d" -ls





share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1016942%2fhow-can-i-find-a-file-whose-name-fits-a-particular-pattern-using-find%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted










    Since you are allowed to use the find command, this is quite simple:



    find / -type f -name "g??.d"


    This will find all files (-type f) with a name that starts
    with g, followed by two arbitrary characters ??, followed
    by .d (-name "g??.d") in the root directory / and below.



    When run as non-root user you will get many permission denied
    errors because not all directories below / are accessible
    by non-root. Also, it may take a while.



    Change / to the path where you want to start the search from,
    e.g. /home/your_user or simply . for the current directory.



    Add -ls to get not only the file's names but also their attributes
    (size, age, permissions):



    find . -type f -name "g??.d" -ls





    share|improve this answer
























      up vote
      4
      down vote



      accepted










      Since you are allowed to use the find command, this is quite simple:



      find / -type f -name "g??.d"


      This will find all files (-type f) with a name that starts
      with g, followed by two arbitrary characters ??, followed
      by .d (-name "g??.d") in the root directory / and below.



      When run as non-root user you will get many permission denied
      errors because not all directories below / are accessible
      by non-root. Also, it may take a while.



      Change / to the path where you want to start the search from,
      e.g. /home/your_user or simply . for the current directory.



      Add -ls to get not only the file's names but also their attributes
      (size, age, permissions):



      find . -type f -name "g??.d" -ls





      share|improve this answer






















        up vote
        4
        down vote



        accepted







        up vote
        4
        down vote



        accepted






        Since you are allowed to use the find command, this is quite simple:



        find / -type f -name "g??.d"


        This will find all files (-type f) with a name that starts
        with g, followed by two arbitrary characters ??, followed
        by .d (-name "g??.d") in the root directory / and below.



        When run as non-root user you will get many permission denied
        errors because not all directories below / are accessible
        by non-root. Also, it may take a while.



        Change / to the path where you want to start the search from,
        e.g. /home/your_user or simply . for the current directory.



        Add -ls to get not only the file's names but also their attributes
        (size, age, permissions):



        find . -type f -name "g??.d" -ls





        share|improve this answer












        Since you are allowed to use the find command, this is quite simple:



        find / -type f -name "g??.d"


        This will find all files (-type f) with a name that starts
        with g, followed by two arbitrary characters ??, followed
        by .d (-name "g??.d") in the root directory / and below.



        When run as non-root user you will get many permission denied
        errors because not all directories below / are accessible
        by non-root. Also, it may take a while.



        Change / to the path where you want to start the search from,
        e.g. /home/your_user or simply . for the current directory.



        Add -ls to get not only the file's names but also their attributes
        (size, age, permissions):



        find . -type f -name "g??.d" -ls






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 18 at 10:20









        PerlDuck

        3,92811030




        3,92811030



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1016942%2fhow-can-i-find-a-file-whose-name-fits-a-particular-pattern-using-find%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            GRUB: Fatal! inconsistent data read from (0x84) 0+xxxxxx

            What makes Checkinstall packages not suitable for distribution?

            Running the scala interactive shell from the command line