chatgpt-4o-latest-20250326· OpenAI
LMArena Human Preference 140K
Give me a linux cli command to list only the subdirectories of the current directory and…
- 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)
- 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 | tacExplanation:
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 -loutput starts withdfor 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.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.