INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Command similar to "ls -lart" (UNIX) in Powershell

Command similar to "ls -lart" (UNIX) in Powershell

(OP)


Hello,

I am looking for the analogous command of "ls -lart" in Powershell.
Anybody knows? By the way, if I am using MSDOS, the analogous command of "ls " is "dir ", so how we can do "ls -lart" in MSDOS? Thank you

RE: Command similar to "ls -lart" (UNIX) in Powershell

ls works in PowerShell. It is an alias for Get-ChildItem just like dir is as well.

What does -lart do?

I suspect what you are looking for is

CODE

Get-ChildItem -Recursive | Sort LastWriteTime 

RE: Command similar to "ls -lart" (UNIX) in Powershell

(OP)
Hello markdmac,

sorry, but the attribute "Lastwritetime" does not exist (at least, in my Windows powershell).
Making "man sort", I get the following attributes available for "sort" command:

Sort-Object [[-property] <Object[]>] [-inputObject <psobject>] [-culture <string>] [-caseSensitive] [-unique] [-des
cending] [<CommonParameters>]

Also, "recursive" is not available, but "recurse", is it what you meant, right?

CODE

Get-ChildItem -Recurse | sort 

Thank you

RE: Command similar to "ls -lart" (UNIX) in Powershell

My apologies, yes I meant Recurse.

CODE --> V4

Get-ChildItem -Recurse | Sort LastWriteTime 


I'd recommend that you upgrade your version of PowerShell to version 4. When I execute the above command this is my output:

    Directory: C:\Users\b121700\Desktop\Scripts


Mode                LastWriteTime     Length Name                                                                                                                                                                               
----                -------------     ------ ----                                                                                                                                                                               
-a---          5/6/2015   2:12 PM       4877 DecomStage2.ps1                                                                                                                                                                    
-a---          5/6/2015   2:55 PM       3641 DecomStage1.ps1 

As you can see, the LastWriteTime property does exist.


I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

RE: Command similar to "ls -lart" (UNIX) in Powershell

(OP)
Thank you for your reply Mark,

Yes, I believed you, the command "LastWriteTime" exists, but it is not available in the version v1.0.
I talked with the administrator and he told me that is not possible to install another version.

So, any ideas how to do it in version 1.0 of Powershell?
Thank you in advance.

RE: Command similar to "ls -lart" (UNIX) in Powershell

Wow, you are many versions behind. Is your admin claiming there are technical reasons they cannot upgrade or compatibility issues with other programs?

Can you execute the commands from another computer that is upgraded? You could use a remote PSSession.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close