Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - ls -h

Reply
 
Old 08-28-2007   #1 (permalink)
Storm Rider
Guest


 
 

ls -h

what would be the "ls -h" equivalent in powershell? (Get-ChildItem
-HumanReadable)

My System SpecsSystem Spec
Old 08-28-2007   #2 (permalink)
Keith Hill [MVP]
Guest


 
 

Re: ls -h

Storm Rider" <Storm Rider@xxxxxx> wrote in message
news:434E3364-4FCD-4CB9-B28A-9FBB054C7037@xxxxxx
Quote:

> what would be the "ls -h" equivalent in powershell? (Get-ChildItem
> -HumanReadable)
Been a long time since using unix style ls. Can you provide a sample of
this type of output or describe a bit more about "HumanReadable"?

--
Keith

My System SpecsSystem Spec
Old 08-29-2007   #3 (permalink)
Storm Rider
Guest


 
 

Re: ls -h

-h use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and
Petabyte in order to reduce the number of digits to four or fewer using base
2 for sizes.


"Keith Hill [MVP]" wrote:
Quote:

> Storm Rider" <Storm Rider@xxxxxx> wrote in message
> news:434E3364-4FCD-4CB9-B28A-9FBB054C7037@xxxxxx
Quote:

> > what would be the "ls -h" equivalent in powershell? (Get-ChildItem
> > -HumanReadable)
>
> Been a long time since using unix style ls. Can you provide a sample of
> this type of output or describe a bit more about "HumanReadable"?
>
> --
> Keith
>
My System SpecsSystem Spec
Old 08-29-2007   #4 (permalink)
Keith Hill [MVP]
Guest


 
 

Re: ls -h

"Storm Rider" <StormRider@xxxxxx> wrote in message news:79F15DDD-F614-418C-8728-5F814AD9D046@xxxxxx
Quote:

> -h use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and
> Petabyte in order to reduce the number of digits to four or fewer using base
> 2 for sizes.
OK it isn't pretty but it works:

gci | format-table `
@{l='Mode';w=5;e={$_.Mode}},
@{l='LastWriteTime';w=22;a="right";e={$_.LastWriteTime}},
@{l='Length';w=12;a='right';e={$_.Length | format-byte}},
Name

Note that this does use the Format-Byte cmdlet from the PowerShell Community Extensions. However if you download and use that, you can set this on a global basis:

233# $PscxFileSizeInUnitsPreference = $true
234# gci


Directory: Microsoft.PowerShell.Core\FileSystem::\Downloads


Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 7/10/2007 11:56 AM 1.16 GB 6.0.6000.0.0.WindowsSDK_Vista_rtm.DVD.Rel.img
-a--- 7/31/2007 10:35 PM 1.144 GB 6.0.6001.16621.148.WindowsSDK_LonghornServer_

--
Keith
http://www.codeplex.com/powershellcx
My System SpecsSystem Spec
Old 08-29-2007   #5 (permalink)
Storm Rider
Guest


 
 

Re: ls -h

Thanks Keith, didn't realize that was already part of PSCX.

Sean

"Keith Hill [MVP]" wrote:
Quote:

> "Storm Rider" <StormRider@xxxxxx> wrote in message
> news:79F15DDD-F614-418C-8728-5F814AD9D046@xxxxxx
Quote:

> > -h use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and
> > Petabyte in order to reduce the number of digits to four or fewer using
> base
Quote:

> > 2 for sizes.
>
> OK it isn't pretty but it works:
>
> gci | format-table `
> @{l='Mode';w=5;e={$_.Mode}},
> @{l='LastWriteTime';w=22;a="right";e={$_.LastWriteTime}},
> @{l='Length';w=12;a='right';e={$_.Length | format-byte}},
> Name
>
> Note that this does use the Format-Byte cmdlet from the PowerShell
> Community Extensions. However if you download and use that, you can set
> this on a global basis:
>
> 233# $PscxFileSizeInUnitsPreference = $true
> 234# gci
>
>
> Directory: Microsoft.PowerShell.Core\FileSystem::\Downloads
>
>
> Mode LastWriteTime Length Name
> ---- ------------- ------ ----
> -a--- 7/10/2007 11:56 AM 1.16 GB
> 6.0.6000.0.0.WindowsSDK_Vista_rtm.DVD.Rel.img
> -a--- 7/31/2007 10:35 PM 1.144 GB
> 6.0.6001.16621.148.WindowsSDK_LonghornServer_
>
> --
> Keith
> http://www.codeplex.com/powershellcx
>
My System SpecsSystem Spec
Reply

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46