Skip to main content
added 44 characters in body
Source Link
Alexander
  • 9.9k
  • 3
  • 42
  • 62

Here's one possible solution:

alias ca='cd $(find . -maxdepth 1 -type d -printf "%T@ %p\n" | sort -n | tail -1 | cut -d" " -f2-)'

However,But it has the disadvantage offollowing problems:

  • Using the output directly from find without using something like print0, which results in directories with spaces in the name to not be handled correctly.
  • Entering . if that is the last modified directory, instead of one of the directories within ..

Here's one possible solution:

alias ca='cd $(find . -maxdepth 1 -type d -printf "%T@ %p\n" | sort -n | tail -1 | cut -d" " -f2-)'

However, it has the disadvantage of:

  • Using the output directly from find without using something like print0, which results in directories with spaces in the name to not be handled correctly.
  • Entering . if that is the last modified directory.

Here's one possible solution:

alias ca='cd $(find . -maxdepth 1 -type d -printf "%T@ %p\n" | sort -n | tail -1 | cut -d" " -f2-)'

But it has the following problems:

  • Using the output directly from find without using something like print0, which results in directories with spaces in the name to not be handled correctly.
  • Entering . if that is the last modified directory, instead of one of the directories within ..
Source Link
Alexander
  • 9.9k
  • 3
  • 42
  • 62

Here's one possible solution:

alias ca='cd $(find . -maxdepth 1 -type d -printf "%T@ %p\n" | sort -n | tail -1 | cut -d" " -f2-)'

However, it has the disadvantage of:

  • Using the output directly from find without using something like print0, which results in directories with spaces in the name to not be handled correctly.
  • Entering . if that is the last modified directory.