I am writing a script that will identify the oldest file in a directory. Here's the syntax:
chmod 777 *
ls -r -1t > file1
sed -n -e "1P" < file1 > file2
So my problem is, now I have file2, which contains the name of the oldest file in the directory. How do I use, say, a cat of file2 as input for a command? Do I need to use a pipe? My main dilemma is how I am going to remove the file named in file2.