8/5/2023 0 Comments Bash find file command![]() ![]() So how about finding files that were accessed or created last n minutes? find Downloads/ -type d -mtime -1 -ls Finding modified directories on the last 1 day Finding files that have been recently accessed or created Similarly, you can find directories on which you worked a few days ago. cache/mozilla/firefox/ -type d -mmin -5 -ls Listing directories that are modified in the last 5 minutes Just change -type f with -type d, which will let you search for directories instead of files.įor demonstration, I'll be showing how you can get the list of modified directories under /.cache/mozilla/firefox: find. The find command can also bring a list of modified directories. mtime +30 Find modified directories in the last n minutes or days Let's say you want to find files older than 30 days in the current directory. You can use the mtime parameter to find older files that have not been modified recently. Suppose I want to find files that have been modified in the last one day, my command would be: find /media/sagar/HDD/Downloads -type f -mtime -1 -ls Finding files modified on the last one day Find files older than X days To find modified files in the last n days instead of n minutes, you just have to use -mtime instead of -mmin. Finding files modified in the last n days You don't necessarily need to use find-exec or xargs for the ls command. ![]() The find command allows a few actions on its result. var/ -type f -mmin -5 -ls Using -ls for better visibility In this case, I'll append -ls to have a much cleaner look and more info such as the file owner, permissions, and modification time. var/ -type f -mmin -5 Finding modified files in the last 5 minutesĪs you can see, it just throws files, and I don't find the given list useful and readable. So let's suppose I want to list find files that are just modified in the last 5 minutes in the var directory my command will be as follows: find. Finding files modified in the last 5 minutes Similarly, you can also use -mtime instead of -mmin to check for files modified days ago. n will check for files modified exactly n minutes ago.+n will check for files modified in more than n minutes.-n will check for files modified in less than n minutes.Here, n indicates how many minutes you want to check for. Finding modified files in Linuxīefore jumping to the explanatory part, first, I'd like to share the syntax of how you can use the find command to find files that are modified at the last n minute. Let me share how you can list files that are accessed and created in the last n minutes/days in detail. The command below will find all the files that have been modified in the last five minutes in the current directory. What log files were modified? What files changed when I ran this command? The versatile find command can help you get the answers. Finding recently modified files is a helpful parameter when troubleshooting your code or server. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |