Tag Info

New answers tagged


As Vivian suggested, the -t option of ls tells it to sort files by modification time (most recent first, by default; reversed if you add -r).  This is most commonly used (at least in my experience) to sort the files in a directory, but it can also be applied to a list of files on the command line.  And wildcards (“globs”) produce a list of files on the ...


This does almost exactly what you want, except it leaves off the trailing / on the directory names. find . -maxdepth 2 -name file1.php -printf '%T@ %h (last modified %Td/%Tm/%TY %Tk:%TM)\n' \ | sort -k 1n | sed 's/^[^ ]* .\///' Credit where credit is due. This is adapted from shlck's answer here. Edit: All of my %A should have been %T


Yes it is quite possible. This will give you files which are modified in last 60 minutes: $ find /domain -type f -mmin -60 or this will give you files which are sorted by modify time. $ find /domain -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r Edit #1 If you have file extensions like you said '.php', add this: -name '*.php' And I found this ...


To delete all but the 3 newest files using a zsh glob, you can use Om (capital O) to sort the files from oldest to newest and a subscript to grab the files you want. rm *(Om[1,-4]) # | |||| ` stop at the 4th to the last file (leaving out the 3 newest) # | |||` start with first file (oldest in this case) # | ||` subscript to pick one or a range of files ...


if [ "$(cp -uv source destination)" != "" ]; then echo copied; else echo not copied; fi Update Match "->" in cp's verbose output. It only occurs if it could be successfully copied and if your filenames do not contain "->". if [[ "$(cp -uv source destination)" =~ \-\> ]]; then echo copied; else echo not copied; fi


ls has two time display formats: For timestamps from the past 6 months: month, day, hour, minute. For other timestamps (in the future, or from more than 6 months ago): year, month, day. The intent is to gain horizontal space and not overwhelm the user with information. Showing “from this year” is more obvious than showing the current year and letting the ...


Problem solved. The problem is that if the date is in the future, it will display the year instead of the hour. Here's a simple example: touch file and l gives -rw-r--r-- 1 ABCD DEF 0 sept. 29 12:01 file whic is normal. No try to change the date to be 15 seconds in the future : touch --date "+15 seconds" file and immediately ls -l -rw-r--r-- 1 ABCD DEF ...

Top 50 recent answers are included