如何在linux中获取大于'x'名称的文件名 [英] How to get the file name which is greater then 'x' name in linux

查看:84
本文介绍了如何在linux中获取大于'x'名称的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我对linux脚本的东西不太熟悉......并且不得不做一些奇怪的事情



我有一个简单的目录,其中有许多YYYYMMDD格式的文件夹......这就是我在目录上执行ls时的样子



[admin @ xxx审计] $ ls

1145 20140827 20140828 20140829 20140830 20140831 20140901 20140902 20140903 20140904 20140905 20141020 20141021 20141022 20141023 20141024 20141025 20141026 20141027 20141028 20141029 20141030 20141031 nohup.out



现在我要做的是将一个文件夹(按升序排列)复制到另一个目录。

我将保存此文件夹名称复制到光盘的某处。



现在我需要再次复制之前复制过的文件夹,依此类推。



例如我将第一个1145复制到目的地并将其保存在last_copied_date.txt中。

现在在下一次运行中我需要读取last_copied_date.txt这个文件夹名称,然后自20140827到1145旁边,将其复制到目的地并用这个新复制的文件夹名称替换last_copied_date.txt中的名称。



再次在第三次运行20140828将被复制(记住1145和20140827仍然存在于那里源目录)和last_copied_date.txt将更新。



任何帮助表示赞赏。

Hi,

I am not so familiar with the linux scripting thing ...and had to do something weird

I have a simple directory which has many folders in YYYYMMDD format... this is how it looks when I do a ls on the directory

[admin@xxx audit]$ ls
1145 20140827 20140828 20140829 20140830 20140831 20140901 20140902 20140903 20140904 20140905 20141020 20141021 20141022 20141023 20141024 20141025 20141026 20141027 20141028 20141029 20141030 20141031 nohup.out

Now what I have to do is copy one folder (in ascending order) to another directory.
I will save this folder name copied somewhere on my disc.

Now I need to copy again the folder which comes after the one which was copied previously and so on.

e.g. I copied first 1145 to the destination and saved it in last_copied_date.txt.
Now in next run I need to read last_copied_date.txt for this folder name and then since 20140827 comes next to 1145, copy it to the destination and replace the name in last_copied_date.txt with this newly copied folder name.

Again in third run 20140828 will be copied (remember 1145 and 20140827 still exists there on source directory) and last_copied_date.txt will be updated.

Any help is appreciated.

推荐答案

ls

1145 20140827 20140828 20140829 20140830 20140831 20140901 20140902 20140903 20140904 20140905 20141020 20141021 20141022 20141023 20141024 20141025 20141026 20141027 20141028 20141029 20141030 20141031 nohup.out



现在我要做的是将一个文件夹(按升序排列)复制到另一个目录。

我将保存此文件夹名称复制一些e在我的光盘上。



现在我需要再次复制之前复制过的文件夹,依此类推。



例如我将第一个1145复制到目的地并将其保存在last_copied_date.txt中。

现在在下一次运行中我需要读取last_copied_date.txt这个文件夹名称,然后自20140827到1145旁边,将其复制到目的地并用这个新复制的文件夹名称替换last_copied_date.txt中的名称。



再次在第三次运行20140828将被复制(记住1145和20140827仍然存在于那里源目录)和last_copied_date.txt将更新。



任何帮助表示赞赏。
ls
1145 20140827 20140828 20140829 20140830 20140831 20140901 20140902 20140903 20140904 20140905 20141020 20141021 20141022 20141023 20141024 20141025 20141026 20141027 20141028 20141029 20141030 20141031 nohup.out

Now what I have to do is copy one folder (in ascending order) to another directory.
I will save this folder name copied somewhere on my disc.

Now I need to copy again the folder which comes after the one which was copied previously and so on.

e.g. I copied first 1145 to the destination and saved it in last_copied_date.txt.
Now in next run I need to read last_copied_date.txt for this folder name and then since 20140827 comes next to 1145, copy it to the destination and replace the name in last_copied_date.txt with this newly copied folder name.

Again in third run 20140828 will be copied (remember 1145 and 20140827 still exists there on source directory) and last_copied_date.txt will be updated.

Any help is appreciated.


这篇关于如何在linux中获取大于'x'名称的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆