What command lists the files created in a specific month and readable for the owner?











up vote
1
down vote

favorite












I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.



I know I'm supposed to use



ls -l


and I will use | somewhere in it but not sure what comes before the pipe and what after.










share|improve this question















migrated from stackoverflow.com Sep 13 '12 at 21:03


This question came from our site for professional and enthusiast programmers.











  • 3




    You should look into the find command. Also, don't attempt to parse ls - see mywiki.wooledge.org/ParsingLs.
    – ziesemer
    Sep 13 '12 at 14:37






  • 2




    I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
    – Isaac Rabinovitch
    Sep 13 '12 at 21:55








  • 1




    First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
    – Cameron Kerr
    Sep 10 '14 at 9:42










  • The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
    – Cameron Kerr
    Sep 10 '14 at 9:46















up vote
1
down vote

favorite












I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.



I know I'm supposed to use



ls -l


and I will use | somewhere in it but not sure what comes before the pipe and what after.










share|improve this question















migrated from stackoverflow.com Sep 13 '12 at 21:03


This question came from our site for professional and enthusiast programmers.











  • 3




    You should look into the find command. Also, don't attempt to parse ls - see mywiki.wooledge.org/ParsingLs.
    – ziesemer
    Sep 13 '12 at 14:37






  • 2




    I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
    – Isaac Rabinovitch
    Sep 13 '12 at 21:55








  • 1




    First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
    – Cameron Kerr
    Sep 10 '14 at 9:42










  • The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
    – Cameron Kerr
    Sep 10 '14 at 9:46













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.



I know I'm supposed to use



ls -l


and I will use | somewhere in it but not sure what comes before the pipe and what after.










share|improve this question















I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.



I know I'm supposed to use



ls -l


and I will use | somewhere in it but not sure what comes before the pipe and what after.







linux command-line terminal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 14 '15 at 6:32









tinlyx

61331532




61331532










asked Sep 13 '12 at 14:35







bangalo











migrated from stackoverflow.com Sep 13 '12 at 21:03


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Sep 13 '12 at 21:03


This question came from our site for professional and enthusiast programmers.










  • 3




    You should look into the find command. Also, don't attempt to parse ls - see mywiki.wooledge.org/ParsingLs.
    – ziesemer
    Sep 13 '12 at 14:37






  • 2




    I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
    – Isaac Rabinovitch
    Sep 13 '12 at 21:55








  • 1




    First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
    – Cameron Kerr
    Sep 10 '14 at 9:42










  • The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
    – Cameron Kerr
    Sep 10 '14 at 9:46














  • 3




    You should look into the find command. Also, don't attempt to parse ls - see mywiki.wooledge.org/ParsingLs.
    – ziesemer
    Sep 13 '12 at 14:37






  • 2




    I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
    – Isaac Rabinovitch
    Sep 13 '12 at 21:55








  • 1




    First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
    – Cameron Kerr
    Sep 10 '14 at 9:42










  • The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
    – Cameron Kerr
    Sep 10 '14 at 9:46








3




3




You should look into the find command. Also, don't attempt to parse ls - see mywiki.wooledge.org/ParsingLs.
– ziesemer
Sep 13 '12 at 14:37




You should look into the find command. Also, don't attempt to parse ls - see mywiki.wooledge.org/ParsingLs.
– ziesemer
Sep 13 '12 at 14:37




2




2




I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55






I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55






1




1




First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42




First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42












The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46




The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46










3 Answers
3






active

oldest

votes

















up vote
0
down vote













For the date range you can use a trick. First create two dummy files with touch like this:



touch -t 201209010000 /tmp/1sept
touch -t 201209302359 /tmp/30sept


As you can check they have now desired creation dates:



$ ls -l 1sept 30sept 
-rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
-rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept


Now you are ready to go with the final command:



find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'


A bit of exmplanation:




  • -type f search for files only

  • -newer ! -and -newer using dummy files as template set dates range you like

  • -exec fires a command on every found file written as {} ;

  • stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name

  • grep '^.r' filter results with regular exception to show only lines starting from
    <anycharacter>r, so checks if read access by the file owner is granted






share|improve this answer























  • Except that ls -l | grep "^r.*Sep" will have the same result and is much faster.
    – mikebabcock
    Sep 15 '12 at 13:50


















up vote
0
down vote













ls -lh should list files in human readable long format (depending on your shell).



Now, you want to grep (that's a filter program) for the ones that match what you're looking for.



For example, to find all the files that say david and that were made in 2011, I could use:



ls -lh | grep "david" | grep "2011"


(Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).



In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh and you should be able to make your own grep command that works.






share|improve this answer






























    up vote
    -1
    down vote













    Try this one. Hope it will help:



    ls -la | grep -e "Sep"





    share|improve this answer



















    • 2




      Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
      – Anaksunaman
      May 10 at 8:30











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    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: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f473842%2fwhat-command-lists-the-files-created-in-a-specific-month-and-readable-for-the-ow%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown
























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    For the date range you can use a trick. First create two dummy files with touch like this:



    touch -t 201209010000 /tmp/1sept
    touch -t 201209302359 /tmp/30sept


    As you can check they have now desired creation dates:



    $ ls -l 1sept 30sept 
    -rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
    -rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept


    Now you are ready to go with the final command:



    find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'


    A bit of exmplanation:




    • -type f search for files only

    • -newer ! -and -newer using dummy files as template set dates range you like

    • -exec fires a command on every found file written as {} ;

    • stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name

    • grep '^.r' filter results with regular exception to show only lines starting from
      <anycharacter>r, so checks if read access by the file owner is granted






    share|improve this answer























    • Except that ls -l | grep "^r.*Sep" will have the same result and is much faster.
      – mikebabcock
      Sep 15 '12 at 13:50















    up vote
    0
    down vote













    For the date range you can use a trick. First create two dummy files with touch like this:



    touch -t 201209010000 /tmp/1sept
    touch -t 201209302359 /tmp/30sept


    As you can check they have now desired creation dates:



    $ ls -l 1sept 30sept 
    -rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
    -rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept


    Now you are ready to go with the final command:



    find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'


    A bit of exmplanation:




    • -type f search for files only

    • -newer ! -and -newer using dummy files as template set dates range you like

    • -exec fires a command on every found file written as {} ;

    • stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name

    • grep '^.r' filter results with regular exception to show only lines starting from
      <anycharacter>r, so checks if read access by the file owner is granted






    share|improve this answer























    • Except that ls -l | grep "^r.*Sep" will have the same result and is much faster.
      – mikebabcock
      Sep 15 '12 at 13:50













    up vote
    0
    down vote










    up vote
    0
    down vote









    For the date range you can use a trick. First create two dummy files with touch like this:



    touch -t 201209010000 /tmp/1sept
    touch -t 201209302359 /tmp/30sept


    As you can check they have now desired creation dates:



    $ ls -l 1sept 30sept 
    -rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
    -rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept


    Now you are ready to go with the final command:



    find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'


    A bit of exmplanation:




    • -type f search for files only

    • -newer ! -and -newer using dummy files as template set dates range you like

    • -exec fires a command on every found file written as {} ;

    • stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name

    • grep '^.r' filter results with regular exception to show only lines starting from
      <anycharacter>r, so checks if read access by the file owner is granted






    share|improve this answer














    For the date range you can use a trick. First create two dummy files with touch like this:



    touch -t 201209010000 /tmp/1sept
    touch -t 201209302359 /tmp/30sept


    As you can check they have now desired creation dates:



    $ ls -l 1sept 30sept 
    -rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
    -rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept


    Now you are ready to go with the final command:



    find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'


    A bit of exmplanation:




    • -type f search for files only

    • -newer ! -and -newer using dummy files as template set dates range you like

    • -exec fires a command on every found file written as {} ;

    • stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name

    • grep '^.r' filter results with regular exception to show only lines starting from
      <anycharacter>r, so checks if read access by the file owner is granted







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 14 '12 at 12:40

























    answered Sep 14 '12 at 12:35









    topr

    547410




    547410












    • Except that ls -l | grep "^r.*Sep" will have the same result and is much faster.
      – mikebabcock
      Sep 15 '12 at 13:50


















    • Except that ls -l | grep "^r.*Sep" will have the same result and is much faster.
      – mikebabcock
      Sep 15 '12 at 13:50
















    Except that ls -l | grep "^r.*Sep" will have the same result and is much faster.
    – mikebabcock
    Sep 15 '12 at 13:50




    Except that ls -l | grep "^r.*Sep" will have the same result and is much faster.
    – mikebabcock
    Sep 15 '12 at 13:50












    up vote
    0
    down vote













    ls -lh should list files in human readable long format (depending on your shell).



    Now, you want to grep (that's a filter program) for the ones that match what you're looking for.



    For example, to find all the files that say david and that were made in 2011, I could use:



    ls -lh | grep "david" | grep "2011"


    (Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).



    In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh and you should be able to make your own grep command that works.






    share|improve this answer



























      up vote
      0
      down vote













      ls -lh should list files in human readable long format (depending on your shell).



      Now, you want to grep (that's a filter program) for the ones that match what you're looking for.



      For example, to find all the files that say david and that were made in 2011, I could use:



      ls -lh | grep "david" | grep "2011"


      (Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).



      In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh and you should be able to make your own grep command that works.






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        ls -lh should list files in human readable long format (depending on your shell).



        Now, you want to grep (that's a filter program) for the ones that match what you're looking for.



        For example, to find all the files that say david and that were made in 2011, I could use:



        ls -lh | grep "david" | grep "2011"


        (Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).



        In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh and you should be able to make your own grep command that works.






        share|improve this answer














        ls -lh should list files in human readable long format (depending on your shell).



        Now, you want to grep (that's a filter program) for the ones that match what you're looking for.



        For example, to find all the files that say david and that were made in 2011, I could use:



        ls -lh | grep "david" | grep "2011"


        (Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).



        In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh and you should be able to make your own grep command that works.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 14 '12 at 13:06









        jokerdino

        2,18711832




        2,18711832










        answered Sep 13 '12 at 21:15









        mikebabcock

        929510




        929510






















            up vote
            -1
            down vote













            Try this one. Hope it will help:



            ls -la | grep -e "Sep"





            share|improve this answer



















            • 2




              Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
              – Anaksunaman
              May 10 at 8:30















            up vote
            -1
            down vote













            Try this one. Hope it will help:



            ls -la | grep -e "Sep"





            share|improve this answer



















            • 2




              Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
              – Anaksunaman
              May 10 at 8:30













            up vote
            -1
            down vote










            up vote
            -1
            down vote









            Try this one. Hope it will help:



            ls -la | grep -e "Sep"





            share|improve this answer














            Try this one. Hope it will help:



            ls -la | grep -e "Sep"






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 10 at 8:27









            Anaksunaman

            5,11321222




            5,11321222










            answered May 10 at 8:12









            Ikram

            1




            1








            • 2




              Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
              – Anaksunaman
              May 10 at 8:30














            • 2




              Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
              – Anaksunaman
              May 10 at 8:30








            2




            2




            Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
            – Anaksunaman
            May 10 at 8:30




            Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
            – Anaksunaman
            May 10 at 8:30


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f473842%2fwhat-command-lists-the-files-created-in-a-specific-month-and-readable-for-the-ow%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido