Save all the file of current date in another dir?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Save all the file of current date in another dir?
# 1  
Old 03-26-2014
Save all the file of current date in another dir?

Hi

i want to copy all the files of current date in another directory.
for example, below i want to save all the file of 26 march to copied in debug dir.

Code:
 
$  ls -lrt | tail -5
-rwxrwxrwx  1 khare  guest        73 Jan  6 12:35 chk
-rw-r--r--  1 khare  guest        770 Mar 26 02:21 cc1
-rw-r--r--  1 khare  guest        770 Mar 26 02:22 cc2
-rw-r--r--  1 khare  guest        770 Mar 26 02:22 cc3
-rw-r--r--  1 khare  guest        770 Mar 26 02:35 cp

i tried using some of the below command but not workin.

Code:
 
 ls -lrt | grep 'Mar 26' | cp -p | awk '{print $9}' /home/guest/khare/debug
 
                                      AND
 
cp -p ls -lrt | grep 'Mar 26' | awk '{print $9}' /home/guest/khare/debug

thx in advance

Regards
Scriptor
# 2  
Old 03-26-2014
well, e.g. lets take your last line:
you cp what?
Code:
cp -p $( ls -lrt | grep 'Mar 26' | awk '{print $9}') /home/guest/khare/debug

OK?
This User Gave Thanks to vbe For This Post:
# 3  
Old 03-26-2014
thx a lot vbe it works
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

2. Shell Programming and Scripting

Subtract a file's modification date with current date

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise Hi, In a folder, there are files. I have a script which reads the current date and subtract the modification date of each file. How do I achieve this? Regards, Joe (2 Replies)
Discussion started by: roshanbi
2 Replies

3. Shell Programming and Scripting

how to copy current date files to another dir

i have directory /abcd and i want to copy all today date files in /xyz directory. i am able to see the files by using below command but not able to understand copy. find . -mtime -1 -type f -exec ls -l {} \; (2 Replies)
Discussion started by: learnbash
2 Replies

4. Shell Programming and Scripting

I need to back up a bunch of files on a directory and save that file as the current date....

this is what i have to find the files modified within the past 24 hours find . -mtime -1 -type f -print0 | xargs -0 tar rvf "$archive.tar" however i need to save/name this archive as the current date (MM-DD,YYYY.tar.gz) how do i doo this (1 Reply)
Discussion started by: bugenhagen_
1 Replies

5. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

6. UNIX and Linux Applications

CPIO Problem, copy to the root dir / instead of current dir

HI all, I got a CPIO archive that contains a unix filesystem that I try to extract, but it extract to the root dir / unstead of current dir, and happily it detects my file are newer otherwise it would have overwrited my system's file! I tried all these commands cpio -i --make-directories <... (2 Replies)
Discussion started by: nekkro-kvlt
2 Replies

7. Shell Programming and Scripting

How to create a dir with name "current date".

I need to create a dir in my script with its name as current date in the server. how can i do that please help. (2 Replies)
Discussion started by: abhishek27
2 Replies

8. Shell Programming and Scripting

to write a script to compare the file size in the current directory and previous dir

hi, i am new to this site. i want to write a script to compare the file size of the files in the current dir with the files in the previous directory. the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to... (5 Replies)
Discussion started by: tweety
5 Replies

9. Shell Programming and Scripting

Perl: Extracting date from file name and comparing with current date

I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date. $file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z really appreciate any help. thanks mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies

10. UNIX for Dummies Questions & Answers

Move A File With Same Date,don't Change The Desitination Dir Date

Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)
Discussion started by: jee.ku2
1 Replies
Login or Register to Ask a Question