Bash script help

Hello,

I need to make a script that will display files of a directory (with full path) and they need to be sorted by modified time (older ones first)

This is what I have done so far:

ls -ldtr `pwd`/* | grep -v "^d"

The probem is that it shows the files of the current directory, but it is needed that I give the directory name from the command line. So the command would be something like:

./oldest.sh dirname

Any ideas how I could add this feature?

Thanks in advance!

ls -ldtr dirname

should work for you. I don't see why not. Okay, so it includes directories. Is your whole point to make a script that takes a parameter from the command line?

#!/bin/ksh
ls -ldtr ${1:.} | grep -v ^-

ls -altr directory name

would do !!

EDIT:

ls -ldtr `pwd`/dirname/* | grep -v "^d" seems to work :slight_smile:

So thanks!