Commands tagged modified files (6)

  • The output format is given by the -printf parameter: %[email protected] = modify time in seconds since Jan. 1, 1970, 00:00 GMT, with fractional part. Mandatory, hidden in the end. %TY-%Tm-%Td %TH:%TM:%.2TS = modify time as YYYY-MM-DD HH:MM:SS. Optional. %p = file path Refer to for more about -printf formatting. ------------------------ sort -nr = sort numerically and reverse (higher values - most recent timestamp - first) head -n 5 = get only 5 first lines (change 5 to whatever you want) cut -f2- -d" " = trim first field (timestamp, used only for sorting) ------------------------ Very useful for building scripts for detecting malicious files upload and malware injections. Show Sample Output

    find . -type f -printf '%[email protected] %TY-%Tm-%Td %TH:%TM:%.2TS %p\n' | sort -nr | head -n 5 | cut -f2- -d" "
    paulera · 2016-03-23 11:56:39 0
  • I sometimes (due to mismanagement!) end up with files in a git repo which have had their modes changed, but not their content. This one-liner lets me revert the mode changes, while leaving changed-content files be, so I can commit just the actual changes made.

    git diff --numstat | awk '{if ($1 == "0" && $2 == "0") print $3}' | xargs git checkout HEAD
    lingo · 2009-09-17 22:12:50 6
  • Only shows files with actual changes to text (excluding whitespace). Useful if you've messed up permissions or transferred in files from windows or something like that, so that you can get a list of changed files, and clean up the rest.

    git diff --numstat -w --no-abbrev | perl -a -ne '$F[0] != 0 && $F[1] !=0 && print $F[2] . "\n";'
    lingo · 2009-08-19 05:07:58 2
  • Here's a way to wait for a file (a download, a logfile, etc) to stop changing, then do something. As written it will just return to the prompt, but you could add a "; echo DONE" or whatever at the end. This just compares the full output of "ls" every 10 seconds, and keeps going as long as that output has changed since the last interval. If the file is being appended to, the size will change, and if it's being modified without growing, the timestamp from the "--full-time" option will have changed. The output of just "ls -l" isn't sufficient since by default it doesn't show seconds, just minutes. Waiting for a file to stop changing is not a very elegant or reliable way to measure that some process is finished - if you know the process ID there are much better ways. This method will also give a false positive if the changes to the target file are delayed longer than the sleep interval for any reason (network timeouts, etc). But sometimes the process that is writing the file doesn't exit, rather it continues on doing something else, so this approach can be useful if you understand its limitations.

    while [ "$(ls -l --full-time TargetFile)" != "$a" ] ; do a=$(ls -l --full-time TargetFile); sleep 10; done
    dmmst19 · 2015-05-09 03:19:49 1
  • This will find all files in the path "." which are older than 10*24hrs (10 days). This will find any type of file.

    find . -mtime +10
    rexington · 2010-04-12 14:50:08 0
  • This command will find any named file types in / between two dates then will list all the metadata of those files in long format and human readable form. Adding a 't' flag to the ls command sorts the files by modified time. After all that the head -5 lists the first 5 which can be changed.

    ls -laht `find / -name "*.*" -type f -newermt "2016-04-05" ! -newermt "2016-04-10"`|head -5
    ubercoo · 2016-04-19 14:26:23 0

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Calculate days on which Friday the 13th occurs (inspired from the work of the user justsomeguy)
Friday is the 5th day of the week, monday is the 1st. Output may be affected by locale.

all out
How to force a userid to log out of a Linux host, by killing all processes owned by the user, including login shells:

run a command from within vi without exiting
":! ls -l " results in listing the files in the current directory. pressing "enter" will get you back into vi.

find process associated with a port
e.g. fuser 25/tcp (see which pid is listening on smtp)

Make a high definition VNC
-nohttpd don't run mini-httpd if VNC java applet is found -name change the name of the desktop, it's passed to xstartup script via $VNCDESKTOP, run different set of apps acording the name. -depth pixel depth in bits of the desktop, default is 16 -geometry size of the desktop, default is 1024x768

execute a command in case of success or execute a command in case of failure

Remove security limitations from PDF documents using QPDF
Remove security restrictions from PDF documents using this very simple command on Linux and OSX. You need QPDF installed ( for this to work.

Find all files larger than 500M and less than 1GB

find both total size and number of files below any given svn directory
afaik, svn doesn't have a good, scriptable way of telling you these two basic pieces of information.

Show word-by-word differences between two latex files, in color

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: