Sponsored Content
Top Forums Shell Programming and Scripting Copy Last modified directory to another directory Post 302442673 by ygemici on Thursday 5th of August 2010 04:54:33 AM
Old 08-05-2010
Code:
# find -maxdepth 1 -type d -exec stat -c %Y%n {} \; | sort -n | tail -1|sed 's/[^.]*//' | xargs cp -rt "your target path"


Last edited by ygemici; 08-05-2010 at 06:04 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl find directory only if modified in last hour

I want a one liner perl command to find a directory only if the modified time is within the last hour I am running this on windows - and I will define a variable for the result. So for example I want to return value of 1 for the variable if the modified time of d:\test1 is within the last... (0 Replies)
Discussion started by: frustrated1
0 Replies

2. Shell Programming and Scripting

Find the directory modified/created before 4 days

Hi, I have an application which creates some directories while running. I want to delete these directories which are 4 days older. i tried find . type d -mtime +1 -print And it is working fine.. but find . type d -mtime +4 -print is not giving any results which are 4 days... (6 Replies)
Discussion started by: Tuxidow
6 Replies

3. UNIX for Advanced & Expert Users

how to open a last modified file in a directory

how to directly open a last modified file in a directory? Please help (5 Replies)
Discussion started by: apsprabhu
5 Replies

4. UNIX for Dummies Questions & Answers

How to get the latest modified file name in /home directory?

I only know how to list all sub-directories or files in specified directory. I don't know how to order them by modified date, furthermore, I don't know how to get the top one file in the sorted list. Wish you can do me a favor. Thanks in advance! (3 Replies)
Discussion started by: crest.boy
3 Replies

5. Shell Programming and Scripting

Copy last modified directory from path using Perl

Hi I need to copy last modified directory from path /users/bin to be copied to /tmp in a perl script ...somehow my script is not allowing me to do cd /users/bin. i have tried $dir = `find /users/bin -maxdepth 1 -type d -mtime 0 ` cp -R $dir /tmp/new but it says missing destination... (1 Reply)
Discussion started by: shaveta
1 Replies

6. Shell Programming and Scripting

last modified directory

hi everyone suppose i have many directory under one directory. now i want to find out the last modified directory so i executed the command ls -ltr but it gives me the directory structure too and i don't want this so i removed 'r' also but it too gives me directory... (2 Replies)
Discussion started by: aishsimplesweet
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. Shell Programming and Scripting

Copy the files in directory and sub folders as it is to another directory.

How to copy files from one directory to another directory with the subfolders copied. If i have folder1/sub1/sub2/* it needs to copy files to folder2/sub1/sub2/*. I do not want to create sub folders in folder2. Can copy command create them automatically? I tried cp -a and cp -R but did... (4 Replies)
Discussion started by: santosh2626
4 Replies

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

10. Shell Programming and Scripting

Printing last modified sub-directory's files

hey, I need to write a command line (only one line), which prints the content of the files of the last modified sub-folder thanks in advance I have to use grep for this (3 Replies)
Discussion started by: sijaanh
3 Replies
HTML::Copy(3pm) 					User Contributed Perl Documentation					   HTML::Copy(3pm)

NAME
HTML::Copy - copy a HTML file without breaking links. VERSION
Version 1.3 SYMPOSIS
use HTML::Copy; HTML::Copy->htmlcopy($source_path, $destination_path); # or $p = HTML::Copy->new($source_path); $p->copy_to($destination_path); # or open my $in, "<", $source_path; $p = HTML::Copy->new($in) $p->source_path($source_path); # can be omitted, # when $source_path is in cwd. $p->destination_path($destination_path) # can be omitted, # when $source_path is in cwd. open my $out, ">", $source_path; $p->copy_to($out); DESCRIPTION
This module is to copy a HTML file without beaking links in the file. This module is a sub class of HTML::Parser. REQUIRED MODULES
HTML::Parser CLASS METHODS
htmlcopy HTML::Copy->htmlcopy($source_path, $destination_path); Parse contents of $source_path, change links and write into $destination_path. parse_file $html_text = HTML::Copy->parse_file($source_path, $destination_path); Parse contents of $source_path and change links to copy into $destination_path. But don't make $destination_path. Just return modified HTML. The encoding of strings is converted into utf8. CONSTRUCTOR METHODS
new $p = HTML::Copy->new($source); Make an instance of this module with specifing a source of HTML. The argument $source can be a file path or a file handle. When a file handle is passed, you may need to indicate a file path of the passed file handle by the method "source_path". If calling "source_path" is omitted, it is assumed that the location of the file handle is the current working directory. INSTANCE METHODS
copy_to $p->copy_to($destination) Parse contents of $source given in new method, change links and write into $destination. The argument $destination can be a file path or a file handle. When $destination is a file handle, you may need to indicate the location of the file handle by a method "destination_path". "destination_path" must be called before calling "copy_to". When calling "destination_path" is omitted, it is assumed that the locaiton of the file handle is the current working directory. parse_to $p->parse_to($destination_path) Parse contents of $source_path given in new method, change links and return HTML contents to wirte $destination_path. Unlike copy_to, $des- tination_path will not created and just return modified HTML. The encoding of strings is converted into utf8. ACCESSOR METHODS
source_path $p->source_path $p->source_path($path) Get and set a source location. Usually source location is specified with the "new" method. When a file handle is passed to "new" and the location of the file handle is not the current working directory, you need to use this method. destination_path $p->destination_path $p->destination_path($path) Get and set a destination location. Usually destination location is specified with the "copy_to". When a file handle is passed to "copy_to" and the location of the file handle is not the current working directory, you need to use this method before "copy_to". enchoding $p->encoding; Get an encoding of a source HTML. io_layer $p->io_layer; $p->io_layer(':utf8'); Get and set PerlIO layer to read the source path and to write the destination path. Usualy it was automatically determined by $source_path's charset tag. If charset is not specified, Encode::Guess module will be used. encode_suspects @suspects = $p->encode_sustects; $p->encode_suspects(qw/shiftjis euc-jp/); Add suspects of text encoding to guess the text encoding of the source HTML. If the source HTML have charset tag, it is not requred to add suspects. source_html $p->source_html; Obtain source HTML's contents NOTE
Cleanuped pathes should be given to HTML::Copy and it's instances. For example, a verbose path like '/aa/bb/../cc' may cause converting links wrongly. This is a limitaion of the URI module's rel method. To cleanup pathes, Cwd::realpath is useful. AUTHOR
Tetsuro KURITA <tkurita@mac.com> perl v5.8.8 2008-03-16 HTML::Copy(3pm)
All times are GMT -4. The time now is 12:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy