Hello,
I am attempting to find and copy the two most recently added files to a specific directory, that fit a specific format.
I was able to find the command to list the two most recently added files in directory:
The command lists the two files names in a vertical list, top being most recent.
Q1: How can I extend this command to only select the most recent files with a specific format?
Q2: How can I copy over the files to a new directory once the proper files are chosen?
Format: 'OUS_*_*_*.html'
Attempt:
I am attempting to find and copy the two most recently added files to a specific directory, that fit a specific format.
I was able to find the command to list the two most recently added files in directory:
Code:
ls -1t | head -n 2
Q1: How can I extend this command to only select the most recent files with a specific format?
Q2: How can I copy over the files to a new directory once the proper files are chosen?
Format: 'OUS_*_*_*.html'
Attempt:
Code:
# Does not select two most recent files
find . -type f $fileNameFormat -exec cp -pf {} $testDestDir \;