show a recursive list of files modified since i last logged in

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











up vote
3
down vote

favorite












I am trying to figure out how to use find to show a list of all files in my current directory and lower that have been modified since my current terminal session was started.



Obviously a recursive find is to be used, but how do i delineate the results to just show files that are modified since i logged in? do i check them against some other file that is always modified on login? Is there a built in way?



say some thing like:
find . -newer 'xxxx' where xxxx is some file that gets modified at the start of a terminal session. But what file would work for that?







share|improve this question

























    up vote
    3
    down vote

    favorite












    I am trying to figure out how to use find to show a list of all files in my current directory and lower that have been modified since my current terminal session was started.



    Obviously a recursive find is to be used, but how do i delineate the results to just show files that are modified since i logged in? do i check them against some other file that is always modified on login? Is there a built in way?



    say some thing like:
    find . -newer 'xxxx' where xxxx is some file that gets modified at the start of a terminal session. But what file would work for that?







    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      I am trying to figure out how to use find to show a list of all files in my current directory and lower that have been modified since my current terminal session was started.



      Obviously a recursive find is to be used, but how do i delineate the results to just show files that are modified since i logged in? do i check them against some other file that is always modified on login? Is there a built in way?



      say some thing like:
      find . -newer 'xxxx' where xxxx is some file that gets modified at the start of a terminal session. But what file would work for that?







      share|improve this question













      I am trying to figure out how to use find to show a list of all files in my current directory and lower that have been modified since my current terminal session was started.



      Obviously a recursive find is to be used, but how do i delineate the results to just show files that are modified since i logged in? do i check them against some other file that is always modified on login? Is there a built in way?



      say some thing like:
      find . -newer 'xxxx' where xxxx is some file that gets modified at the start of a terminal session. But what file would work for that?









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jun 28 at 1:33
























      asked Jun 28 at 1:26









      DanMan3395

      717




      717




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          There's no specific file you can use for this, but it's easy to add your own.



          In your .profile or .bash_profile or whatever you could do something like



          TIMEFILE=$HOME/.lastlogin
          [[ ! -f $TIMEFILE ]] && touch $TIMEFILE
          find $HOME -newer $TIMEFILE
          touch $TIMEFILE


          The [[ line is there to prevent find from complaining if the file doesn't exist.



          Edit: Ah, sorry, I may have slightly misunderstood your question. You may want to run the command at any time, so in this case you could just have this in your .bash_profile



          touch $HOME/.lastlogin


          And now from the command line



          find $HOME -newer $HOME/.lastlogin


          You can reset the timer at any time by touching the file again.






          share|improve this answer























          • ok so each time my shell is invoked it makes a new file and then uses it as the time baseline?
            – DanMan3395
            Jun 28 at 2:13










          • It's important to do the find before the touch. So you use the previous timestamp file (ie your previous login) for the comparison, then update the timestamp when it completes. Or if you just want to run the command at any time, the touch command in your .bash_profile is sufficient, and you can run the find command at any time.
            – Stephen Harris
            Jun 28 at 2:16











          • Ah, I may have slightly misunderstood your question, so I added some additional discussion to the answer.
            – Stephen Harris
            Jun 28 at 2:24










          • This makes sense thank you. Just curious, is there some other, built in way to search for files modified since login? My original assumption was find but i want to make sure i am not overthinking something simple.
            – DanMan3395
            Jun 28 at 2:28

















          up vote
          0
          down vote













          In Bash you could calculate the time that has passed since you logged in, with last.



          TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 ))


          Note that this will yield a negative number. (That's useful for the next step.)



          Then you add the time difference with the -mmin parameter to the find command:



          find . -mmin $TIMEDIFF


          Of course you can also make it a one-liner.






          share|improve this answer





















          • This doesn't work for me as the find just shows everything that exists. I also get weird results from the code in that variable: TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 )) date: invalid date ‘134.29.149.192 Wed Jun 27’
            – DanMan3395
            Jun 28 at 2:11











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f452332%2fshow-a-recursive-list-of-files-modified-since-i-last-logged-in%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          There's no specific file you can use for this, but it's easy to add your own.



          In your .profile or .bash_profile or whatever you could do something like



          TIMEFILE=$HOME/.lastlogin
          [[ ! -f $TIMEFILE ]] && touch $TIMEFILE
          find $HOME -newer $TIMEFILE
          touch $TIMEFILE


          The [[ line is there to prevent find from complaining if the file doesn't exist.



          Edit: Ah, sorry, I may have slightly misunderstood your question. You may want to run the command at any time, so in this case you could just have this in your .bash_profile



          touch $HOME/.lastlogin


          And now from the command line



          find $HOME -newer $HOME/.lastlogin


          You can reset the timer at any time by touching the file again.






          share|improve this answer























          • ok so each time my shell is invoked it makes a new file and then uses it as the time baseline?
            – DanMan3395
            Jun 28 at 2:13










          • It's important to do the find before the touch. So you use the previous timestamp file (ie your previous login) for the comparison, then update the timestamp when it completes. Or if you just want to run the command at any time, the touch command in your .bash_profile is sufficient, and you can run the find command at any time.
            – Stephen Harris
            Jun 28 at 2:16











          • Ah, I may have slightly misunderstood your question, so I added some additional discussion to the answer.
            – Stephen Harris
            Jun 28 at 2:24










          • This makes sense thank you. Just curious, is there some other, built in way to search for files modified since login? My original assumption was find but i want to make sure i am not overthinking something simple.
            – DanMan3395
            Jun 28 at 2:28














          up vote
          2
          down vote



          accepted










          There's no specific file you can use for this, but it's easy to add your own.



          In your .profile or .bash_profile or whatever you could do something like



          TIMEFILE=$HOME/.lastlogin
          [[ ! -f $TIMEFILE ]] && touch $TIMEFILE
          find $HOME -newer $TIMEFILE
          touch $TIMEFILE


          The [[ line is there to prevent find from complaining if the file doesn't exist.



          Edit: Ah, sorry, I may have slightly misunderstood your question. You may want to run the command at any time, so in this case you could just have this in your .bash_profile



          touch $HOME/.lastlogin


          And now from the command line



          find $HOME -newer $HOME/.lastlogin


          You can reset the timer at any time by touching the file again.






          share|improve this answer























          • ok so each time my shell is invoked it makes a new file and then uses it as the time baseline?
            – DanMan3395
            Jun 28 at 2:13










          • It's important to do the find before the touch. So you use the previous timestamp file (ie your previous login) for the comparison, then update the timestamp when it completes. Or if you just want to run the command at any time, the touch command in your .bash_profile is sufficient, and you can run the find command at any time.
            – Stephen Harris
            Jun 28 at 2:16











          • Ah, I may have slightly misunderstood your question, so I added some additional discussion to the answer.
            – Stephen Harris
            Jun 28 at 2:24










          • This makes sense thank you. Just curious, is there some other, built in way to search for files modified since login? My original assumption was find but i want to make sure i am not overthinking something simple.
            – DanMan3395
            Jun 28 at 2:28












          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          There's no specific file you can use for this, but it's easy to add your own.



          In your .profile or .bash_profile or whatever you could do something like



          TIMEFILE=$HOME/.lastlogin
          [[ ! -f $TIMEFILE ]] && touch $TIMEFILE
          find $HOME -newer $TIMEFILE
          touch $TIMEFILE


          The [[ line is there to prevent find from complaining if the file doesn't exist.



          Edit: Ah, sorry, I may have slightly misunderstood your question. You may want to run the command at any time, so in this case you could just have this in your .bash_profile



          touch $HOME/.lastlogin


          And now from the command line



          find $HOME -newer $HOME/.lastlogin


          You can reset the timer at any time by touching the file again.






          share|improve this answer















          There's no specific file you can use for this, but it's easy to add your own.



          In your .profile or .bash_profile or whatever you could do something like



          TIMEFILE=$HOME/.lastlogin
          [[ ! -f $TIMEFILE ]] && touch $TIMEFILE
          find $HOME -newer $TIMEFILE
          touch $TIMEFILE


          The [[ line is there to prevent find from complaining if the file doesn't exist.



          Edit: Ah, sorry, I may have slightly misunderstood your question. You may want to run the command at any time, so in this case you could just have this in your .bash_profile



          touch $HOME/.lastlogin


          And now from the command line



          find $HOME -newer $HOME/.lastlogin


          You can reset the timer at any time by touching the file again.







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Jun 28 at 2:23


























          answered Jun 28 at 2:05









          Stephen Harris

          21.1k23771




          21.1k23771











          • ok so each time my shell is invoked it makes a new file and then uses it as the time baseline?
            – DanMan3395
            Jun 28 at 2:13










          • It's important to do the find before the touch. So you use the previous timestamp file (ie your previous login) for the comparison, then update the timestamp when it completes. Or if you just want to run the command at any time, the touch command in your .bash_profile is sufficient, and you can run the find command at any time.
            – Stephen Harris
            Jun 28 at 2:16











          • Ah, I may have slightly misunderstood your question, so I added some additional discussion to the answer.
            – Stephen Harris
            Jun 28 at 2:24










          • This makes sense thank you. Just curious, is there some other, built in way to search for files modified since login? My original assumption was find but i want to make sure i am not overthinking something simple.
            – DanMan3395
            Jun 28 at 2:28
















          • ok so each time my shell is invoked it makes a new file and then uses it as the time baseline?
            – DanMan3395
            Jun 28 at 2:13










          • It's important to do the find before the touch. So you use the previous timestamp file (ie your previous login) for the comparison, then update the timestamp when it completes. Or if you just want to run the command at any time, the touch command in your .bash_profile is sufficient, and you can run the find command at any time.
            – Stephen Harris
            Jun 28 at 2:16











          • Ah, I may have slightly misunderstood your question, so I added some additional discussion to the answer.
            – Stephen Harris
            Jun 28 at 2:24










          • This makes sense thank you. Just curious, is there some other, built in way to search for files modified since login? My original assumption was find but i want to make sure i am not overthinking something simple.
            – DanMan3395
            Jun 28 at 2:28















          ok so each time my shell is invoked it makes a new file and then uses it as the time baseline?
          – DanMan3395
          Jun 28 at 2:13




          ok so each time my shell is invoked it makes a new file and then uses it as the time baseline?
          – DanMan3395
          Jun 28 at 2:13












          It's important to do the find before the touch. So you use the previous timestamp file (ie your previous login) for the comparison, then update the timestamp when it completes. Or if you just want to run the command at any time, the touch command in your .bash_profile is sufficient, and you can run the find command at any time.
          – Stephen Harris
          Jun 28 at 2:16





          It's important to do the find before the touch. So you use the previous timestamp file (ie your previous login) for the comparison, then update the timestamp when it completes. Or if you just want to run the command at any time, the touch command in your .bash_profile is sufficient, and you can run the find command at any time.
          – Stephen Harris
          Jun 28 at 2:16













          Ah, I may have slightly misunderstood your question, so I added some additional discussion to the answer.
          – Stephen Harris
          Jun 28 at 2:24




          Ah, I may have slightly misunderstood your question, so I added some additional discussion to the answer.
          – Stephen Harris
          Jun 28 at 2:24












          This makes sense thank you. Just curious, is there some other, built in way to search for files modified since login? My original assumption was find but i want to make sure i am not overthinking something simple.
          – DanMan3395
          Jun 28 at 2:28




          This makes sense thank you. Just curious, is there some other, built in way to search for files modified since login? My original assumption was find but i want to make sure i am not overthinking something simple.
          – DanMan3395
          Jun 28 at 2:28












          up vote
          0
          down vote













          In Bash you could calculate the time that has passed since you logged in, with last.



          TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 ))


          Note that this will yield a negative number. (That's useful for the next step.)



          Then you add the time difference with the -mmin parameter to the find command:



          find . -mmin $TIMEDIFF


          Of course you can also make it a one-liner.






          share|improve this answer





















          • This doesn't work for me as the find just shows everything that exists. I also get weird results from the code in that variable: TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 )) date: invalid date ‘134.29.149.192 Wed Jun 27’
            – DanMan3395
            Jun 28 at 2:11















          up vote
          0
          down vote













          In Bash you could calculate the time that has passed since you logged in, with last.



          TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 ))


          Note that this will yield a negative number. (That's useful for the next step.)



          Then you add the time difference with the -mmin parameter to the find command:



          find . -mmin $TIMEDIFF


          Of course you can also make it a one-liner.






          share|improve this answer





















          • This doesn't work for me as the find just shows everything that exists. I also get weird results from the code in that variable: TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 )) date: invalid date ‘134.29.149.192 Wed Jun 27’
            – DanMan3395
            Jun 28 at 2:11













          up vote
          0
          down vote










          up vote
          0
          down vote









          In Bash you could calculate the time that has passed since you logged in, with last.



          TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 ))


          Note that this will yield a negative number. (That's useful for the next step.)



          Then you add the time difference with the -mmin parameter to the find command:



          find . -mmin $TIMEDIFF


          Of course you can also make it a one-liner.






          share|improve this answer













          In Bash you could calculate the time that has passed since you logged in, with last.



          TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 ))


          Note that this will yield a negative number. (That's useful for the next step.)



          Then you add the time difference with the -mmin parameter to the find command:



          find . -mmin $TIMEDIFF


          Of course you can also make it a one-liner.







          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jun 28 at 2:04









          Lukas

          1




          1











          • This doesn't work for me as the find just shows everything that exists. I also get weird results from the code in that variable: TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 )) date: invalid date ‘134.29.149.192 Wed Jun 27’
            – DanMan3395
            Jun 28 at 2:11

















          • This doesn't work for me as the find just shows everything that exists. I also get weird results from the code in that variable: TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 )) date: invalid date ‘134.29.149.192 Wed Jun 27’
            – DanMan3395
            Jun 28 at 2:11
















          This doesn't work for me as the find just shows everything that exists. I also get weird results from the code in that variable: TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 )) date: invalid date ‘134.29.149.192 Wed Jun 27’
          – DanMan3395
          Jun 28 at 2:11





          This doesn't work for me as the find just shows everything that exists. I also get weird results from the code in that variable: TIMEDIFF=$(( ( $(date --date="$(last -1 | head -n 1 | tr -s " " | cut -d" " -f3-6)" +%s) - $(date +%s) ) / 60 )) date: invalid date ‘134.29.149.192 Wed Jun 27’
          – DanMan3395
          Jun 28 at 2:11













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452332%2fshow-a-recursive-list-of-files-modified-since-i-last-logged-in%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          The Forum (Inglewood, California)

          Palaiologos