Unix dir按日期时间排序目录,并选择所有目录,留下前n个目录

时间:2017-01-31 07:15:37

标签: sorting unix directory

我有一个目录,其中包含N个子目录。现在,我需要按最后修改的日期和时间对它们进行排序,然后我需要选择所有目录,留下前n个目录。

我做了dir -td */来排序。我试过dir -td */ | head -n 5这实际上不起作用。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

试试这个。

$(function() {
    $(".playButton").on('click',function() {
      var iframeObj = $(".flex-active-slide iframe")[0];
      var currentURL = iframeObj.src;

        if(currentURL.indexOf("autoplay=") == -1)
        {
            //autoplay not present in src; so lets add it
            currentURL = currentURL + '?autoplay=1'
        }
        else{
            if(currentURL.indexOf("autoplay=1")>-1){
                //replace autoplay=1 with autoplay=0
                currentURL = currentURL.replace('autoplay=1', 'autoplay=0');
            }
            else
            {
                //replace autoplay=0 with autoplay=1
                currentURL = currentURL.replace('autoplay=0', 'autoplay=1');
            }
        }

        iframeObj.src = currentURL; //set the newer src to iframe

    });
});

使用find和tail命令可以实现此目的。对于tail命令,需要+符号。所以,只有它跳过第n个目录。