I am trying to put the output of a bash command (filename) into a string for later access.
echo "$(ls -Art | tail -n 1)"
successfully prints out the latest file updated in the directory (good).
The problem occurs when I try to store this into a var. to access later in the script.
Any suggestions on how to do so? I've seen different methods, but it didn't seem to work/ apply because I'm using the param -Art for ls.
Thanks!
further info: filename still gets kicked back as the {actual filename}: command not found
filename = `ls -Art | tail -n 1`
$ x=$(ls -Art | tail -n 1) $ echo $x