English 中文(简体)
利用指挥系统查找档案并存档,日期附后 需要一个单一的指挥所
原标题:Using find command to find files and archive them with date appended- Need a single find command
  • 时间:2012-01-13 00:53:49
  •  标签:
  • unix
  • find

I am trying to find files which are created/modified 30 days ago and will archive them. For this i am using Unix Find command. I am able to achieve the requirement with below command line.

 find . -type f -mtime +30  -exec basename {} ; | xargs -I file_name echo mv /home/Cyrup/chip/arc_poc/file_name /home/Cyrup/chip/arc_poc/arc/file_name_$(date +%Y%m%d) | ksh

However I would like to perform this task just using find command which i am not able to achieve. I tried to use below:

find . -type f -mtime +30 -exec mv {} /home/Cyrup/chip/arc_poc/arc/{}_`date +%Y%m%d` ;

但是,它没有努力。 这里,如果{}在发现指挥所查明的所有档案中担任地方持有人。 然后,将档案移至Dir档案,重新命名,就错了吗?

Also -mtime is for modified time of the file. Is there any way that we can find files based on creation time of the file. As per my knowledge we do not have any option with find command.

增 编

问题回答

不可能在<条码>限定的指令中这样做。 您可以撰写一份更名的文字,取代<代码>mv:

find . -type f -mtime +30 -exec appenddate.sh {} ;

With appenddate.sh being something like:

mv $1 $1_`date +%Y%m%d`




相关问题
Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Function to create the array by reading the file

I am creating scripts which will store the contents of pipe delimited file. Each column is stored in a separate array. I then read the information from the arrays and process it. There are 20 pipe ...

Compare characters at the end of the string C++

This program supposed to find command line arguments entered on Unix which ends with “.exe”. For some reason it doesn t work. Here is the code: int main( int argc, char* argv[] ) { for ( int ...

Batch Job Dependencies Using Open Source/Free Software

I run a large data warehouse plant where we have a lot of nightly jobs running concerruently however many have dependencies on a extract or data load process before they start. Currently we use an ...

Writing application for both Unix and Windows

I ll write a program for Interactive UNIX (http://en.wikipedia.org/wiki/INTERACTIVE_UNIX). But in a year it will be ported to Windows. I ll write it in ANSI C and/or SH-script. When it runs on Windows ...

Development Environment in Windows [closed]

What are your recommendations for setting up a development environment in Windows, especially when not using an IDE. I am attempting to familiarize myself with Windows, and I feel a bit lost. What ...

热门标签