Sponsored Content
Top Forums Shell Programming and Scripting Copying latest file into a folder Post 302301371 by takissd on Thursday 26th of March 2009 04:49:31 PM
Old 03-26-2009
hello there, i tried it and it doesnt work Smilie
I tried to code below:

Code:
PREVLATEST=""
while [ 1 ]; do
LATEST=`ls -tr /var/Folder1/ | tail -1`
if [ "${LATEST}" != "${PREVLATEST}" ]; then
  cp "/var/Folder1/${LATEST}" "/var/Folder2/${LATEST}"
  PREVLATEST="${LATEST}"
done

I save this on a file.sh then i run it at the startup as a daemon.

Seems like nothing is happening.
any directions?
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Copying files with the latest date

Hi All, I have a situation where I need to copy the files having the latest date. For example I have a file by name bas100e1_jun05. I need to copy it to bas100e1. But when a file by name bas100e1_jul05 is put in the same directory the script should copy the file having the latest month which... (34 Replies)
Discussion started by: shashi_kiran_v
34 Replies

2. UNIX for Dummies Questions & Answers

Copy the latest file from a folder

Hi, I have a problem. I have some text files in a folder. The names can be like: emp_20080307053015.dat emp_20080306053015.dat emp_20080305053015.dat emp_20080304053015.dat The date format appended is like yyyymmdd and timestamp. What i need is i have to copy the latest file every... (3 Replies)
Discussion started by: Aswarth
3 Replies

3. Shell Programming and Scripting

copying the latest file

Hi, I have a problem. I have some text files in a folder. The names can be like: emp_20080307053015.dat emp_20080306053015.dat emp_20080305053015.dat emp_20080304053015.dat The date format appended is like yyyymmdd and timestamp. What i need is i have to copy the latest file every... (12 Replies)
Discussion started by: Aswarth
12 Replies

4. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

5. UNIX for Dummies Questions & Answers

Copy the latest (last file) in given folder

#!/bin/bash for i in {1..1536..1} do #find /home/test/Desktop/up111/workplace/Malware/$i/logs for a in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do #max=a for b in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do ... (4 Replies)
Discussion started by: upvan111
4 Replies

6. UNIX and Linux Applications

Need to copy the latest file from Unix server to Shared folder

Hi All, One job in unix server will generate .csv files daily. I need to copy the latest of these .csv file from the unix server to the shared drive/folder in windows through unix script. My shared folder will look something like W:\some folder(for example). Could any one of you please help... (3 Replies)
Discussion started by: jaya@123
3 Replies

7. Shell Programming and Scripting

Perl : copying only the latest file to other directory

In linux.. In a directory there are 3 files which I want to copy only the latest file (ls -ltr myfiles*.txt|tail -1) to other directory in perl? Could anyone please help me with the code? Regards, J (1 Reply)
Discussion started by: scriptscript
1 Replies

8. UNIX for Dummies Questions & Answers

Copying a file based on a incremented folder name

I need to routinely cp a file out of the highest incremented folder named PROD_2_6.1_xxx where xxx (3 numerical values) is incremented only once a night starting at 100 and ending 999 over a period of time. I am not worried about copying a subset of a complete file while it is being created by some... (5 Replies)
Discussion started by: sf_cb
5 Replies

9. UNIX for Beginners Questions & Answers

Retrieve the Latest file in a folder using SFTP

HI Guys, Can anyone help me to retrieve the latest file from below example using SFTP I have below list of files in a folder v403t.lstprgms.sortin1 val027.d099.fwest.oct2711 xcelrptd.d1400sqp.dec1713.t040459.@02del xcelrptd.d1400sqp.dec1713.t073308.@02del... (3 Replies)
Discussion started by: heye18
3 Replies
MOUNTD(8)						    BSD System Manager's Manual 						 MOUNTD(8)

NAME
mountd -- service remote NFS mount requests SYNOPSIS
Obsolete. See nfsd(8). DESCRIPTION
The mountd daemon was formerly the server for NFS mount requests from NFS clients. This functionality has been moved into the NFS server daemon nfsd(8). Please refer to nfsd(8) for NFS server documenation. The following is a list of former mountd options that are now available as nfsd(8) options: mountd option nfsd option Description -n -N allow non-root mounts -r -R allow regular file mounts exportsfile -F exportsfile alternate exports file However, such configuration options are normally specified via nfs.conf(5). When the NFS server is started, it loads the export host addresses and options into the kernel using the nfssvc(2) system call. After chang- ing the list of exports (either directly or indirectly via a change in netgroup membership), the administrator should send a hangup signal to the nfsd daemon to get it to reload the export information: kill -s HUP `cat /var/run/nfsd.pid` For backwards compatibility, the following should also work: kill -s HUP `cat /var/run/mountd.pid` Any errors encountered while processing the export entries will be logged via syslog(3). FILES
/etc/exports the list of exported filesystems /var/run/mountd.pid the pid of the currently running mountd /var/run/mountdtab the current list of outstanding mounts served /var/run/mountdexptab information about exported file systems and directories (UUIDs, handles, ...) SEE ALSO
nfsd(8), exports(5), nfs.conf(5), nfsstat(1), portmap(8), showmount(8) HISTORY
The mountd utility first appeared in 4.4BSD. It's functionality was merged into nfsd(8) in Darwin 9. BSD
November 10, 2006 BSD
All times are GMT -4. The time now is 03:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy