{"id":490,"date":"2018-08-27T16:59:30","date_gmt":"2018-08-27T15:59:30","guid":{"rendered":"http:\/\/hslomka.de\/techno\/?p=490"},"modified":"2026-03-25T10:16:28","modified_gmt":"2026-03-25T10:16:28","slug":"powershell-equivalent-zu-unix-ls-ltr-tail","status":"publish","type":"post","link":"https:\/\/techno.slomka.biz\/?p=490","title":{"rendered":"\ud83d\udca1Powershell Tip: Equivalent to Unix &#8216;ls -ltr | tail&#8217;"},"content":{"rendered":"\n<p>In PowerShell, the output of the latest n files can be obtained with this command:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers kasten\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#EEFFFF;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#304047;color:#d5ffff\">PowerShell<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#EEFFFF;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly> \u00a0\u00a0Get-ChildItem\u00a0|\u00a0sort LastWriteTime\u00a0|\u00a0Select -Last 60<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme\" style=\"background-color: #263238\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #EEFFFF\"> \u00a0\u00a0<\/span><span style=\"color: #82AAFF\">Get-ChildItem<\/span><span style=\"color: #EEFFFF\">\u00a0<\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #EEFFFF\">\u00a0sort LastWriteTime\u00a0<\/span><span style=\"color: #89DDFF\">|<\/span><span style=\"color: #EEFFFF\">\u00a0Select <\/span><span style=\"color: #89DDFF\">-<\/span><span style=\"color: #EEFFFF\">Last <\/span><span style=\"color: #F78C6C\">60<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In this example, the files in the current directory are output using gci, sorted by last write access using sort (newest last), and then only the last 60 are output using select last 60.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related posts<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/techno.slomka.biz\/?p=501\" data-type=\"link\" data-id=\"https:\/\/techno.slomka.biz\/?p=501\">\ud83d\udca1Powershell Tip: Tail und Head vereint<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/techno.slomka.biz\/?p=494\" data-type=\"link\" data-id=\"https:\/\/techno.slomka.biz\/?p=494\">\ud83d\udca1PowerShell Tip for Large Files \u2013 The Get-Content -Tail and -Wait parameters<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/techno.slomka.biz\/?p=1018\" data-type=\"link\" data-id=\"https:\/\/techno.slomka.biz\/?p=1018\">\ud83d\udca1How to Extract Specific Lines from a File: sed, awk, head\/tail, grep, and with powershell<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In PowerShell, the output of the latest n files can be obtained with this command: In this example, the files in the current directory are output using gci, sorted by last write access using sort (newest last), and then only the last 60 are output using select last 60. Related posts<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,38],"tags":[78,100],"class_list":["post-490","post","type-post","status-publish","format-standard","hentry","category-middleware","category-powershell","tag-powershell","tag-tail"],"_links":{"self":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts\/490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=490"}],"version-history":[{"count":4,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts\/490\/revisions"}],"predecessor-version":[{"id":1178,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=\/wp\/v2\/posts\/490\/revisions\/1178"}],"wp:attachment":[{"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techno.slomka.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}