Hello I'm trying to make a list of the age or the elapsed time since the last modification of my files. It should look this way: File xy 2 days 3 hours 11 minutes File yz 1 month 5 days 7 hours 23 minutes I tried to do this with "ls -l" and awk for the values, but it's the wrong way. I did not found anything like filedate - sysdate. I prefer bash, put perl will be fine too :- TIA Fluppi. Click here to see the post LQ members have rated as the most helpful post in this thread.
I found the solution. This top helped me! Full Answer. Reason: Clerification and spelling correction. Thread Tools. BB code is On. Smilies are On. All times are GMT The time now is PM. Twitter: linuxquestions. Open Source Consulting Domain Registration. Visit Jeremy's Blog. Search Blogs. Also you can disable the support for access time so it could be implemented similarly and then disabled if you really didn't want it. Add a comment. Based on answer by Gilles, here is a bash function that returns file age in seconds or error.
HalosGhost 4, 10 10 gold badges 30 30 silver badges 40 40 bronze badges. Nicholas Sushkin Nicholas Sushkin 2 2 silver badges 3 3 bronze badges. Neat function , easy to adapt by adding simple division to see age in Hour, Days, week Hauke Laging 78k 17 17 gold badges silver badges bronze badges.
Guido Rizzi Guido Rizzi 21 1 1 bronze badge. Lri Lri 4, 1 1 gold badge 24 24 silver badges 19 19 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Linked See more linked questions. Related 9. Hot Network Questions. Question feed. Accept all cookies Customize settings. Of course there would be quite a few of those on a Linux system.
The find command is quite flexible and accepts numerous options. We have only covered a couple of the options here but if you want to check out more of them take a look at find's man page. Most of find's options can be combined to find files which meet several criteria.
To do this we can just continue to list criteria like we did when finding. The syntax is a little tricky but an example is usually all it takes to get it right. Before using the -exec option, especially with a powerful command like rm I recommend performing the same find without the? By doing this you will see exactly which files you will be effecting when you run the final command. The following is a practical example that finds files less than three days old with the. Here we have used rm but it is often useful to use this option with cp or chmod.
Finally the end of the? The find command is great for finding files and directories but next we'll look at some options for finding other things on the system.
If you use find a lot and you probably will you will sometimes run into the problem where you get just pages and pages of output like this:. This is find telling you there are certain directories you don't have permissions to search. This can make it very difficult to find the useful output of the find as it can be mixed in with the permissions errors. To ignore these and any other errors and just get the results of what you can find we can use a special redirect at the end of the command.
While it would not be a good idea to redirect the error output all the time usually you want to know when something has gone wrong in this case of the find command it can be very useful. The grep command can be used to check a file for a specific string. If grep finds that string it will print the line it found it on to the screen.
Here's an example:. It was found and grep printed the line it was found on. The commands we have been executing exist as files somewhere on the system. The which command is used to find the full path of these commands.
0コメント