You are not logged in.

#1 2013-09-30 06:19:42

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

[solved] Shell command to show recently used/modified files

Hi there,

Does anyone know a handy command for the shell to list all recently used or modified files?

I was thinking about some sort of `ls` command but it should be universal and not limited to a specific directory.

Thanks!

Last edited by orschiro (2013-09-30 12:31:37)

Offline

#2 2013-09-30 06:23:37

ebal
Member
From: Athens, Greece
Registered: 2009-05-26
Posts: 224
Website

Re: [solved] Shell command to show recently used/modified files

If you want to find your distro's files that have altered the below command is what you are looking for:

sudo pacman -Qk

if you want to find your files - man find


https://balaskas.gr
Linux System Engineer - Registered Linux User #420129

Offline

#3 2013-09-30 08:41:49

Alber
Member
From: Spain - España
Registered: 2011-11-11
Posts: 227

Re: [solved] Shell command to show recently used/modified files

Hello

ls plus option recursive:

ls -R
ls -R ./
ls -R /home/

and -l for data

ls -Rl

maybe a grep afterwards.

Edit:
Option -ct for sort by last time modification: But it doesn't mix directories.

ls -Rlct

Edit 2:
Option -r for sort reverse: But it doesn't mix directories.

ls -rRlct

Last edited by Alber (2013-09-30 08:55:52)


Because not all of us are native English speakers, try no to use slang or abbreviations, thank you.

Offline

#4 2013-09-30 08:46:40

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,731
Website

Re: [solved] Shell command to show recently used/modified files

Use find.  This finds anything modified 1 day ago for example:

% find /foo -type f -mtime -1

Offline

#5 2013-09-30 08:56:59

wirr
Member
Registered: 2009-10-25
Posts: 70

Re: [solved] Shell command to show recently used/modified files

new_command_like_ls() {
    find $1 -maxdepth $2 -type f -mtime -1 -printf "%T@-%Tk:%TM - %f\n" | sort -rn | cut -d- -f2-
}

Maybe you want to be able to change -mtime to -atime or -ctime.
And you want some error handling smile

Offline

#6 2013-09-30 12:30:57

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] Shell command to show recently used/modified files

graysky wrote:

Use find.  This finds anything modified 1 day ago for example:

% find /foo -type f -mtime -1

Nice, thanks a lot! I like the simplicity. smile

I am going with that one now:

alias recent='find * -type f -mtime -1 | tail'

But thanks for all the other suggestions as well.

Last edited by orschiro (2013-09-30 12:31:27)

Offline

#7 2013-09-30 12:42:55

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,731
Website

Re: [solved] Shell command to show recently used/modified files

You realize the * in your statement is meant to be a path, no?

Offline

#8 2013-09-30 12:44:15

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] Shell command to show recently used/modified files

Why do I need a path if I want to search system-wide for recently modified files?

Offline

#9 2013-09-30 13:10:33

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,731
Website

Re: [solved] Shell command to show recently used/modified files

Path in that case would be /
...if you run as normal user you will get some permission denied errors with 600 and 700 files.

Last edited by graysky (2013-09-30 13:11:31)

Offline

#10 2013-09-30 13:33:15

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] Shell command to show recently used/modified files

graysky wrote:

Path in that case would be /
...if you run as normal user you will get some permission denied errors with 600 and 700 files.

But then I do not really understand why my command posted above also works fine.

[orschiro@thinkpad ~]$ find * -type f -mtime -1 | tail
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/hooks/post-update.sample
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/hooks/pre-applypatch.sample
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/description
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/packed-refs
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/info/exclude
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/index
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/HEAD
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/refs/heads/master
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/refs/remotes/origin/HEAD
Projects/Linux/PKGBUILD/tasky/src/tasky/src/tasky.py

It just lists files that reside in /home.

Last edited by orschiro (2013-09-30 13:33:31)

Offline

#11 2013-09-30 13:39:35

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,731
Website

Re: [solved] Shell command to show recently used/modified files

orschiro wrote:
graysky wrote:

Path in that case would be /
...if you run as normal user you will get some permission denied errors with 600 and 700 files.

But then I do not really understand why my command posted above also works fine.

[orschiro@thinkpad ~]$ find * -type f -mtime -1 | tail
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/hooks/post-update.sample
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/hooks/pre-applypatch.sample
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/description
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/packed-refs
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/info/exclude
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/index
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/HEAD
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/refs/heads/master
Projects/Linux/PKGBUILD/tasky/src/tasky/.git/refs/remotes/origin/HEAD
Projects/Linux/PKGBUILD/tasky/src/tasky/src/tasky.py

It just lists files that reside in /home.

You are likely executing the command from your home dir.  If you want a system wide report, you will specify /

Offline

#12 2013-09-30 13:47:16

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [solved] Shell command to show recently used/modified files

True, that makes sense. Thanks!

Offline

#13 2013-09-30 14:36:39

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: [solved] Shell command to show recently used/modified files

Yeah, the '*' as the first parameter for find just expands to all the files in the current directory (except for dot files). Which is a more verbose way of just saying '.'.

Offline

Board footer

Powered by FluxBB