Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

How to copy the two most recently added files to another directory - HP-UX?

$
0
0
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:
Code:

ls -1t | head -n 2
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:

Code:

# Does not select two most recent files
find . -type f $fileNameFormat -exec cp -pf {} $testDestDir \;


Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images