Any tool to find files modified on specific days?

Using applications, configuring, problems
Message
Author
User avatar
nic007
Posts: 3408
Joined: Sun 13 Nov 2011, 12:31
Location: Cradle of Humankind

#41 Post by nic007 »

Slightly off topic but still looking for an application to find files in real time like "everything" the Windows programme. I want results as I'm typing the query.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#42 Post by MochiMoppel »

musher0 wrote:The one-liner in the attached works as well as your hair-splitting.
Do you really find it funny to garnish ignorance with insults?
I took it for granted that you would test your original code.

To filter files that match the month "Apr" your original code uses the condition $2=="Apr".
When tree outputs a line like
[1.3K Apr 15 2:58]  /path/to/file1
awk sees 5 fields. The month is the 2nd field, so $2=="Apr" will match.

In case of small files tree will output
[    9 Apr 15 2:58]  /path/to/file2
awk sees 6 fields. The bracket is the 1st field, the size (here 9 bytes) is the 2nd and the month has now become the 3rd field. $2=="Apr" will not match. You will never see small files in your search results, not for April or any other month. Never! This is bad. This is a bug!

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#43 Post by musher0 »

Thank you your bringing that quirk to my attention. I had not anticipated it.

Solution:
If we remove the "h" parameter from the tree command, only bytes, not composites, are
shown in the size field. Then all the fields provided by < tree > remain at the same
position whatever the size of the file.

What is left to do is to push up all < awk > fields by one. We do not have to impose a
special field delimiter to awk if we simply want to see a general list of files with their date.

If we want to show the entire line, the awk { print } statement is not required. If we want
to see only the filenames with their path, we will add { print $NF } exactly before the
second apostrophe.

Since a date is a number, we need to add the -n parameter in the < sort > section before
mentioning the field to sort on.

The DIR variable can be defined beforehand or stated directly. Like so:

Code: Select all

DIR=" < Whatever is needed > " # Can be /, ~, /usr, /opt, etc.
tree -Dfis $DIR | awk '$3=="Apr" && $4 ~ /14|15|16/ && $5 ~ /:/' | sort -n -k 4
Depending on the goal we are seeking,
-- one or more parameters, such as -a, -x, -p or --timefmt=%Y-%m-%d, etc., may need
to be added to the < tree > parameters already used;

-- similarly concerning the field delimiter and/or other operations in the < awk > section;

-- finally we may wish to change the column of the < sort > to bring one field or another
into focus -- and remove or keep the -n parameter if that field is alphabetical or numeric.

For example, if we wish to limit the list to
-- files only, leaving out symlinks and directories,
-- in /opt,
-- modified on April 14, 15 and 16 of this year, and
-- see only the filenames with their path,
-- sorted alphabetically,
we could use the following one-liner:

Code: Select all

tree -Dfisp /opt | awk '$3=="Apr" && $4 ~ /14|15|16/ && $5 ~ /:/ && $1 !~ /d|l/ { print $NF }' | sort 
Since the permissions information provided by the -p parameter in < tree > is tacked
directly against the beginning bracket, the previously stated < awk > section does not
need to be altered (except for the addition of { print $NF }). However, since in this case
we are sorting alphabetical material on a single column, a simple < sort > at the end will
do the job.

Best regards.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

hamoudoudou

mtime with pfind works well

#44 Post by hamoudoudou »

mtime with pfind works well / sort result by date size by click on the concerned column..
* means all then tick mtime and choose dates
Atime access time
Ctime changed time
Attachments
time.jpg
too many results found !
(9 KiB) Downloaded 143 times

Post Reply