I'm making a bash script that has to (amongst other things I figured out myself) delete the oldest file in a directory. I have an idea how to do it, but there's something I can't translate from common sense into a bash script.
I can list the files sorted by date with 'ls -c /whatever/path' and get the number of files with 'ls /whatever/path | wc -w'. Now all I have to do is set a variable with its value of whatever is the last word 'ls -c' outputs, or word number [number of files]. How exactly can I do that?
Thanks in advance, if I made enough sense to get an answer