Skip to content
TheChatArchiveThe Chat Archive
chatgpt-4o-latest-20250326· OpenAIHugging Face LMArena Human Preference 140K

Give me a linux cli command to list only the subdirectories of the current directory and…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-7-sonnet-20250219’s answer.
  1. User

    Give me a linux cli command to list only the subdirectories of the current directory and in the reversed order of their modification data (the newest at the very bottom)

  2. Assistant

    You can use the following Linux command in the terminal to list only the subdirectories of the current directory, sorted by modification time in reverse order (newest at the bottom):

    ls -lt --group-directories-first | grep ^d | tac
    

    Explanation:

    • ls -lt: Lists items sorted by modification time, newest first.
    • --group-directories-first: Puts directories at the top of the list.
    • grep ^d: Filters only directories (ls -l output starts with d for directories).
    • tac: Reverses the list (so the newest directories go to the bottom).

    Alternative using find (more robust):

    find . -maxdepth 1 -type d ! -name '.' -printf "%T@ %p\n" | sort -n | cut -d' ' -f2-
    
    • find . -maxdepth 1 -type d: Finds only directories at top level.
    • ! -name '.': Excludes the current . directory.
    • -printf "%T@ %p\n": Prints the modification time (%T@) and path.
    • sort -n: Sorts by numeric value of modification time (oldest first).
    • cut -d' ' -f2-: Removes the timestamp, showing only the directory paths.

    Let me know if you require hidden directories to be included too.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.