Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Copy files from one drive to another, keeping most recently modified files Post 302898445 by apocolapse on Tuesday 22nd of April 2014 08:52:47 AM
Old 04-22-2014
Hi SriniShoo, thanks for the solution. Just so I can try to understand and assist with my scripting learning, is this what your script does?:

Code:
for i in /x/path/*    //for file i within /x/path/example/example1
do
  if [[ ! -f /y/path/${i##*/} || ${i} -nt /y/path/${i##*/} ]]; then   //if file i in /x/path/example/example1 exists then see if file i from X drive is less than file i from Y drive
    cp ${i} /y/path/${i##*/}     //if file i from X drive is less than file i from Y drive (or it doesn't exist in Y drive) copy file i from X drive to same location in Y drive.
  fi        // end if
done     // end do loop

I have a quick question, what does ${i##*/} give? And how does the script know to use date modified? Is there a command for that, or is it used by default?

Thanks!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

copy files from local drive to telnet unix machine.

i want to run some solaris executable program (text file). i telnet to solaris machine. the text file is on the net drive h: or my local drive on windows system. how can i copy the text file from local drive in windows to remote machine in solaris system? thanks. (4 Replies)
Discussion started by: gary
4 Replies

2. UNIX for Dummies Questions & Answers

How do copy certain files and directories from one hard drive to another?

I have two drives (scsi) mounted on one server and I need to copy certain files and directories from one drive to the other. Any suggestions :confused: (4 Replies)
Discussion started by: shorty
4 Replies

3. UNIX for Dummies Questions & Answers

chmod command for recently modified files

hello! is there a way for me to use the chmod command to change permissions for several files all at once -based on the fact that these files were all most recently modified TODAY ? I can't use a wildcard on their filenames because the filenames are varied. But I was hoping I could somehow do... (2 Replies)
Discussion started by: polka_friend
2 Replies

4. Shell Programming and Scripting

Trying to Copy Files Changed Recently

I have been toying around with a script that will copy all files altered in a development directory over to a testing directory and have been trying to construct the command to meet my needs. Basically I am using find in a directory to see what files have changed over the past 24 hours. Then if... (4 Replies)
Discussion started by: scotbuff
4 Replies

5. UNIX for Advanced & Expert Users

command for recently modified files - "find" command not working

I have three files a.txt , b.txt , c.txt in a directory called my_dir1 .These files were created before two or three months . I have a tar file called my_tar1.tar which contains three files a.txt , b.txt , d.txt . Somebody untarred the my_tar1.tar into my_dir1 directory. So existing two files were... (1 Reply)
Discussion started by: joe.mani
1 Replies

6. Shell Programming and Scripting

Using RCP to copy and delete the files from Windows Drive

Hi, I have a requirement to copy the files from C drive on Windows to UNIX, once the files are copied I need to delete them from that drive (C:). A drive is also on same network as my unix, so I was asked to use RCP for copying the files. Can any one have the syntax to copy the files from... (0 Replies)
Discussion started by: Raamc
0 Replies

7. Shell Programming and Scripting

subtring and copy recently files and another folder

Hi I have the following files A320_ZONAL_v24_-_AMM_Suffix_jess_2011-05-31.xls Jun 10 17:21 A320_ZONAL_v24_-_AMM_Suffix_jess_.xls Nov 10 17:21 A320_ZONAL_v24_-_AMM_Suffix_jess_2011-03-31.xls Nov 23 20:21 And I need only the more recent one using UNIX timestamp... (2 Replies)
Discussion started by: javeiregh
2 Replies

8. Shell Programming and Scripting

I want to copy all files of a said type on my external hard drive

My code is this, what I'm trying to accomplish is to make a list of all pdf documents in my computer and then copy all of those documents to my external hard drive in a directory mkdir /Volumes/Hardrive-1/allpdf echo "File Locations" > /Volumes/Hardrive-1/allpdf/FileLocations.txt mdfind pdf... (2 Replies)
Discussion started by: darpness
2 Replies

9. Shell Programming and Scripting

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

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: ls -1t | head -n 2 The command lists the two files names in a vertical list,... (11 Replies)
Discussion started by: mattkoz
11 Replies

10. UNIX for Beginners Questions & Answers

Modified or latest files copy from windows to Linux

To copy the file from windows to linux i use pscp command(pscp source user@destination). Know i want to copy the latest modified or created files from windows to linux. could any one please help me out with it. Thanks and Regards, Sourabh (2 Replies)
Discussion started by: SourabhChavan
2 Replies
MLXCONTROL(8)						    BSD System Manager's Manual 					     MLXCONTROL(8)

NAME
mlxcontrol -- Mylex DAC-family RAID management utility SYNOPSIS
mlxcontrol <command> [args] mlxcontrol status [-qv] [drive] mlxcontrol rescan controller [controller ...] mlxcontrol detach drive [drive ...] mlxcontrol detach -a mlxcontrol check drive mlxcontrol config controller mlxcontrol help command DESCRIPTION
The mlxcontrol utility provides status monitoring and management functions for devices attached to the mlx(4) driver. Controller names are of the form "mlxN" where N is the unit number of the controller. Drive names are of the form "mlxdN" where N is the unit number of the drive. Do not specify the path to a device node. status Print the status of controllers and system drives. If one or more drives are specified, only print information about these drives, otherwise print information about all controllers and drives in the system. With the -v flag, display much more verbose informa- tion. With the -q flag, do not print any output. This command returns 0 if all drives tested are online, 1 if one or more drives are critical and 2 if one or more are offline. rescan Rescan one or more controllers for non-attached system drives (e.g. drives that have been detached or created subsequent to driver initialisation). If the -a flag is supplied, rescan all controllers in the system. detach Detach one or more system drives. Drives must be unmounted and not opened by any other utility for this command to succeed. If the -a flag is supplied, detach all system drives from the nominated controller. check Initiate a consistency check and repair pass on a redundant system drive (e.g. RAID1 or RAID5). The controller will scan the system drive and repair any inconsistencies. This command returns immediately; use the status command to monitor the progress of the check. rebuild Requires two arguments, controller and physdrive as specified in the output of the status command. All system drives using space on the physical drive physdrive are rebuilt, reconstructing all data on the drive. Note that each controller can only perform one rebuild at a time. This command returns immediately; use the status command to monitor the progress of the rebuild. config Print the current configuration from the nominated controller. This command will be updated to allow addition/deletion of system drives from a configuration in a future release. help Print usage information for command. AUTHORS
The mlxcontrol utility was written by Michael Smith <msmith@FreeBSD.org>. BUGS
The config command does not yet support modifying system drive configuration. Error log extraction is not yet supported. BSD
April 10, 2000 BSD
All times are GMT -4. The time now is 07:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy