Say you want to sort the output of “ls” (Get-ChildItem) according to file size, date modified or alphabetically, try: 1. Sort according to file size: ls | sort -property Length 2. Sort according to data modified: ls | sort -property LastWriteTime 3. Sort according to Name: ls | sort -property Name To return a descending [...]

12
Aug
stored in: Powershell and tagged:

Answer: Yes there is! Prodigy Mark Russinovich wrote the Windows counterpart of UNIX’s indispensable du command called, uhm, du: http://technet.microsoft.com/en-us/sysinternals/bb896651.aspx Copy du.exe to %Windir%/System32. (The /usr/bin equivalent of Windows). To obtain the size of top level subdirectories in a directory, with the largest on first in Bash@Linux, we type: du –max-depth=1 | sort -r The [...]

11
Aug
stored in: Powershell and tagged:

UNIX users who are so used to grep would ask “how do I grep in Powershell?”. Here’s how: In Bash we write: ls | grep “.aspx” The equivalent in Powershell would be: ls | where {$_ -match “.aspx”} Bash@Linux output: [root@gw-1 easilogin]# ls -all | grep “.aspx” -rwxrwSrwt 1 root root 682 Jul 29 20:38 [...]