Sponsored Content
Top Forums Shell Programming and Scripting Copy the latest file from one directory to another Post 302341966 by zaxxon on Friday 7th of August 2009 04:28:23 AM
Old 08-07-2009
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

*****************************************************

One possible way:
Code:
cp -p `ls -tr1 a/b/processed| tail -1` a/b/data

Take care of paths or relative paths. Your example is not exact enough to exclude all possible error sources.
If you want to make sure there is no directory etc. being tried to be copied by this you might want to add -F to the ls and grep for the type of file you want to copy. They will be marked by one of this */=>@|.
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Copy the latest file to a directory

Hi Team, I wish to copy the latest file of pattern "MyFile*" to some other location. I need to do all the operation in a single command separated by |. ls -rt <MyFile*> | tail -1 | <copy command>. How can I do? Please help me. Thanks, Kanda (2 Replies)
Discussion started by: spkandy
2 Replies

3. Shell Programming and Scripting

copy the latest file in the remote server's directory

Hi Expert Team, I performed the below piece of code to copy the latest file in the remote server's directory to the same server's other directory. But it is not working properly. How can i handle this? Can you please help me..? ssh ${REMOTE_USERID}@${REMOTE_HOSTNAME} "cp -p `ssh... (3 Replies)
Discussion started by: spkandy
3 Replies

4. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

5. Shell Programming and Scripting

Need to copy latest file using SFTP

Hi All, In my unix server, I have the following files: h1.txt h2.txt h3.txt and through SFTP i need to copy only the latest file to another unix server. Can you please let me know what command i need to use. Thanks in Advance, (2 Replies)
Discussion started by: HemaV
2 Replies

6. Shell Programming and Scripting

Copy latest generated file

Hi, There is csv file generated at /usr/data on server1 on monthly basis. It is in the format reportYYYYDD(e.g 201105). I needed a script which would copy the latest generated file from the location to another server at /usr/loc Please can you help? (2 Replies)
Discussion started by: Alok Ranjan
2 Replies

7. Shell Programming and Scripting

to pick the latest file modified in a directory

I wan to pick the latest modified file name and redirect it to a file .. ls -tr | tail -1 >file but this is printing file ins side the filename , can anyone help me out (5 Replies)
Discussion started by: vishwakar
5 Replies

8. 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

9. 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

10. UNIX for Dummies Questions & Answers

To find the latest modified file in a directory

I am trying to fetch the latest modified file from a directory using the command find . -type f -exec ls -lt \{\} \+ | head | awk '{print $9}' After the O/P, I get the below mentioned error and the command doesnt terminate at all. find: ls terminated by signal 13 find: ls terminated by... (2 Replies)
Discussion started by: Sree10
2 Replies
BLAZE-MAKE(1)						    BlazeBlogger Documentation						     BLAZE-MAKE(1)

NAME
blaze-make - generates a blog from the BlazeBlogger repository SYNOPSIS
blaze-make [-cpqrIFPTV] [-b directory] [-d directory] blaze-make -h|-v DESCRIPTION
blaze-make reads the BlazeBlogger repository, and generates a complete directory tree of static pages, including blog posts, single pages, monthly and yearly archives, tags, and even an RSS feed. OPTIONS
-b directory, --blogdir directory Allows you to specify a directory in which the BlazeBlogger repository is placed. The default option is a current working directory. -d directory, --destdir directory Allows you to specify a directory in which the generated blog is to be placed. The default option is a current working directory. -c, --no-css Disables creating a style sheet. -I, --no-index Disables creating the index page. -p, --no-posts Disables creating blog posts. -P, --no-pages Disables creating pages. -T, --no-tags Disables creating tags. -r, --no-rss Disables creating the RSS feed. -F, --full-paths Enables including page names in generated links. -q, --quiet Disables displaying of unnecessary messages. -V, --verbose Enables displaying of all messages, including a list of created files. -h, --help Displays usage information and exits. -v, --version Displays version information and exits. FILES
.blaze/theme/ A directory containing blog themes. .blaze/style/ A directory containing style sheets. .blaze/lang/ A directory containing language files. EXAMPLE USAGE
Generate a blog in a current working directory: ~]$ blaze-make Done. Generate a blog in the "~/public_html/" directory: ~]$ blaze-make -d ~/public_html Done. Generate a blog with full paths enabled: ~]$ blaze-make -F Done. SEE ALSO
blaze-init(1), blaze-config(1), blaze-add(1) BUGS
To report a bug or to send a patch, please, add a new issue to the bug tracker at <http://code.google.com/p/blazeblogger/issues/>, or visit the discussion group at <http://groups.google.com/group/blazeblogger/>. COPYRIGHT
Copyright (C) 2009-2011 Jaromir Hradilek This program is free software; see the source for copying conditions. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Version 1.2.0 2012-03-05 BLAZE-MAKE(1)
All times are GMT -4. The time now is 12:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy