首页 \ 问答 \ 如何查找具有特定名称的最新文件?(How to find newest files with a certain name?)

如何查找具有特定名称的最新文件?(How to find newest files with a certain name?)

假设我在子目录中有一个包含许多同名文件的目录(例如,在为多篇学术论文保留BibTeX文件时出现)。

查找具有给定名称的文件的最新版本的最佳方法是什么?

我想出了以下命令

find . -name "someFile" -exec ls -alF {} \;

它列出了所有名为someFile的文件及其日期,但不会将它们从旧到新排序。

请注意,此处不能使用ls-t选项,因为它是针对每个文件单独运行的。


Suppose I have a directory with many files of the same name in subdirectories (for example, comes up when keeping BibTeX files for multiple academic papers).

What's the best way to find the newest version of a file with a given name?

I've come up with the following command

find . -name "someFile" -exec ls -alF {} \;

which lists all the files named someFile along with their dates, but does not sort them from old to new.

Note that the -t option to ls can't be used here because it is being run separately for each file.


原文:https://stackoverflow.com/questions/28862590
更新时间:2022-11-06 15:11

最满意答案

分号是在这里,如果你包括这个脚本只是在一些“坏”脚本后,没有正确关闭其最后一行与分号。 在这种情况下,两个脚本可能会被组合并导致无效的代码。 例如,如果您将多个脚本合并到单个响应中。

()结束执行该函数。 这是创建一个关闭。 私有变量和方法可以在此函数的范围内声明,无法从脚本外部访问。


The semi-colon is there in case you include this script just after some 'bad' script that doesn't properly close off its last line with a semi-colon. In this case it's possible the two scripts would be combined and result in invalid code. For example if you are merging multiple script into a single response.

The () at the end is executing the function. This is creating a closure. Private variables and methods can be declared within the scope of this function that cannot be accessed from outside the script.

相关问答

更多
  • 它是为了防止任何先前的代码作为函数的参数执行代码。 即 mybrokenfunction = function(){ } //no semicolon here (function(g){ })(this); 将以您的匿名函数作为参数执行mybrokenfunction: mybrokenfunction = function(){}(function(g){})(this); 如果你可以保证在你的函数之前不会有一个没有终止的(不是分号)函数,你可以省略开始的分号,但是你不能,所以把这个额外的分号 ...
  • 分号是在这里,如果你包括这个脚本只是在一些“坏”脚本后,没有正确关闭其最后一行与分号。 在这种情况下,两个脚本可能会被组合并导致无效的代码。 例如,如果您将多个脚本合并到单个响应中。 ()结束执行该函数。 这是创建一个关闭。 私有变量和方法可以在此函数的范围内声明,无法从脚本外部访问。 The semi-colon is there in case you include this script just after some 'bad' script that doesn't properly close ...
  • 它转换为布尔值。 第一个! 否定一次,转换像这样的值: undefined为true null为true +0为true -0为true '' true NaN为true false到true 所有其他表达式为false 然后另一个! 再次否定它 一个简洁的转换为布尔值,完全相当于ToBoolean,因为! 被定义为它的否定 。 这里不必要,因为它只用作条件运算符的条件,这将以相同的方式确定真实性。 It casts to boolean. The first ! negates it once, conv ...
  • :input是一个jQuery扩展,而input是一个CSS选择器。 textarea , button和select元素将被前者匹配,而不是后者。 后者更快,所以使用它为您的具体radio示例。 使用:input当您想要“所有表单元素”时:input ,即使它们不是严格的标签。 即使在这种情况下,建议首先使用标准CSS选择器,然后在该集合上使用.filter(':input') 。 因为:input是一个jQuery扩展,而不是CSS规范的一部分,使用:input的查询不能利用本机DOM q ...
  • GO只涉及SSMS - 它不是实际的Transact SQL,它只是告诉SSMS按顺序在各个批次之间的每个GO之间发送SQL语句。 的; 是一个SQL语句分隔符,但在大多数情况下,引擎可以解释您的语句被分解的位置。 主要例外,地点在哪里; 最常用的是在普通表表达式之前。 GO only relates to SSMS - it isn't actual Transact SQL, it just tells SSMS to send the SQL statements between each GO in ...
  • 这意味着for循环的初始化器部分没有声明 同样,如果你想跳过for循环的增量部分,它看起来就像 for( ; nCount > 0; ){ // some code } // which is like while loop 从JLS开始,这是for循环的格式 BasicForStatement: for ( ForInitopt ; Expressionopt ; ForUpdateopt ) Statement 你可以看到所有3个都是可选的 that means there is no ...
  • 通过查看分号,可以知道一个单元格的数据已经完成,现在它必须开始在下一个单元格中填充数据。 通过使用分号,您还可以仅使用一个out.write()语句填充多个单元格中的数据,即out.write("somedata;someotherdata;"); 。 这是语言之美。 By seeing a semicolon it gets to know that one cell's data is completed and now it has to begin filling data in the next ...
  • 正如Sybren的评论所述,您应该使用参数进行查询。 或者你也可以使用String.format()来使这看起来更好。 对于该问题,搜索prin_serial_txt.getText()并在Query字符串中进行正确的连接。 As said in the comment by Sybren, you should use parameters for your query. Or you can also use String.format() to make this look better. For t ...
  • 因为; 只是一个空语句,换句话说就是空语句 。 这通常没用,但完全有效。 这在循环中用于重复执行某些操作,但不希望添加循环体。如下例所示: for ( i = 0; i < 10; line[i++] = 0 ) ; 但是,在你的情况下,第一个分号是语句的结尾,第二个是空语句。它是无用的,编译器将忽略它。 Because ; is just an empty statement in other words null statement. It's usually useless but complet ...
  • 第二个分号将被解释为空语句 [spec] 。 它没有任何效果。 我相信引擎会忽略它,但这实际上取决于引擎。 The second semicolon would be interpreted as empty statement [spec]. It does not have any effect. I would believe that engines just ignore it, but that really depends on the engine.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)