![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Urgent !!! Shell script to copy files to VSS | devalin | Shell Programming and Scripting | 1 | 08-20-2007 06:16 AM |
| find files and copy into a directory | balireddy_77 | Shell Programming and Scripting | 4 | 04-27-2007 03:38 AM |
| shell script: deleting files from a directory | onlyc | Shell Programming and Scripting | 1 | 07-09-2006 06:41 AM |
| shell script to find files | naren_samba2005 | Shell Programming and Scripting | 2 | 10-21-2005 05:06 AM |
| find files with a perticular year of access | pradeepmacha | UNIX for Advanced & Expert Users | 3 | 07-12-2005 03:31 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
shell script to find and copy the files creted in the year 2006 to another directory
Hi All,
I am new to UNIX. I will be thankful if some one helps me. I have to write a shell script for one of the requirement. I have files created from Jan 2006 to March 2008. My requirement is to write a script in such a way that 1) To find and copy(not Moving) the files created in the year 2006 to another directory(xyz). The shell should automatically create the directory in the currect path. 2) Then the compress the folder(xyz), which contains all the files created in the year 2006. Thanks in advance. Regards manas |
|
||||
|
The regular solution would be find but it's a bit unwieldy, and it is better at relative age (more than 1 year old, etc) than at finding all files from a particular year. I would whip up a quick Perl script for finding the files; the rest should be trivial enough to leave as an exercise for you.
Code:
perl -e 'for $file (<*>) {
next unless -f $file;
my @s = stat($file);
my @d = localtime($s[10]);
print "$file\n" if $d[5] == 106; } # 1900 + 206 = 2006'
|
|
||||
|
Code:
ls -l | awk '$8==2006{print $NF}' | xargs -i cp "{}" /destination
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|