Windows Vista Forums

Discrepancy with ls -R ?
  1. #1


    Robert Aldwinckle Guest

    Discrepancy with ls -R ?

    I'm trying to use Powershell more often when I would normally be using cmd.

    Today I wanted to expand the information that this cmd command gives:

    dir/a/b/s/p msvcr90*

    so I tried this in Powershell (on W7 X64 as an Admin ICIM):

    PS C:\> ls -Fi msvcr90* -R | fl | more

    I love the extra detail that that provides but am disturbed to see that it
    completely misses an instance of the target file here:


    C:\>dir/a/b/s/p msvcr9*
    C:\MSOCache\All Users\{20140000-0115-0409-1000-0000000FF1CE}-C\msvcr90.dll




    However, if I navigate to that directory separately PS has no trouble giving
    me the desired information

    PS C:\> cd MSOCache
    PS C:\MSOCache> ls -Fi msvcr90* -R | fl


    Directory: C:\MSOCache\All
    Users\{20140000-0115-0409-1000-0000000FF1CE}-C

    Does anybody have some explanation for this as something that I should be
    aware of and watch out for? Any workaround? It looks like something is
    wrong with the implementation of the -Recurse option which would make this
    technique seem unreliable.

    <help>
    DESCRIPTION
    The Get-ChildItem cmdlet gets the items in one or more specified
    locations. If the item is a container, it gets the items inside the
    container, known as child items. You can use the Recurse parameter to get
    items in all child containers.
    </help>


    Oh. -Force finds it but that seems unnecessary. E.g. dir finds it
    without the /a switch:

    C:\>dir/b/s/p msvcr9*
    C:\MSOCache\All Users\{20140000-0115-0409-1000-0000000FF1CE}-C\msvcr90.dll

    PS C:\> icacls MSOCache
    MSOCache NT AUTHORITY\SYSTEMOI)(CI)(F)
    BUILTIN\AdministratorsOI)(CI)(F)


    *and* then much of the elegance of the technique is lost in a hail of
    "Accessed...denied" messages as other really inaccessible directories (to an
    Administrator?) are tested and the failure of those tests reported. ; ]


    So it looks like -Recurse is the analog of the dir/s and -Force is a
    (verbose!) analog of dir/a? Now all I need I suppose is to find
    -NoVerbose option so the dir/a/s/p complete analog will be
    ls -Fo -R -NoV | more. It may take some time before I am used to
    typing that in hurry. And that still leaves discovering how to get a
    dir/b effect too. ; )


    TIA

    Robert Aldwinckle
    ---


      My System SpecsSystem Spec

  2. #2


    Larry__Weiss Guest

    Re: Discrepancy with ls -R ?

    I'm not sure about the particulars of ls -R but I wanted to
    share a bit of trickery that I'm using to use PowerShell cmdlets
    instread of cmd.exe's dir command, yet type the same command line
    when I use them.

    In my profile.ps1 I have a section to define functions like

    function dir/od { dir $args | sort LastWriteTime }
    function dir/o-d { dir $args | sort LastWriteTime -Descending}
    function dir/os { dir $args | ? { !$_.PSIsContainer } | sort Length }
    function dir/o-s { dir $args | ? { !$_.PSIsContainer } | sort Length
    -Descending}
    function dir/os/a-d { dir $args | ? { !$_.PSIsContainer } | sort Length }
    function dir/o-s/a-d { dir $args | ? { !$_.PSIsContainer } | sort Length
    -Descending}
    function dir/ad { dir $args | ? { $_.PSIsContainer } }
    function dir/a-d { dir $args | ? { !$_.PSIsContainer } }
    function dir/ah { dir $args -force | ? { $_.Attributes –band
    [IO.FileAttributes]::Hidden } }
    function dir/od/a-d { dir $args | ? { !$_.PSIsContainer } | sort LastWriteTime }
    function dir/o-d/a-d { dir $args | ? { !$_.PSIsContainer } | sort
    LastWriteTime -Descending}
    function dir/b { dir $args | select Name }

    So, once you get a good equivalent PowerShell construction to
    dir/a/b/s/p
    you might want to define a function named dir/a/b/s/p
    to help you use it.

    I don't have my recursive variations on those above tested yet.

    - Larry


    On 5/7/2010 3:31 PM, Robert Aldwinckle wrote:

    > I'm trying to use Powershell more often when I would normally be using cmd.
    >
    > Today I wanted to expand the information that this cmd command gives:
    >
    > dir/a/b/s/p msvcr90*
    >
    > so I tried this in Powershell (on W7 X64 as an Admin ICIM):
    >
    > PS C:\> ls -Fi msvcr90* -R | fl | more
    >
    > I love the extra detail that that provides but am disturbed to see that
    > it completely misses an instance of the target file here:
    >
    >
    > C:\>dir/a/b/s/p msvcr9*
    > C:\MSOCache\All Users\{20140000-0115-0409-1000-0000000FF1CE}-C\msvcr90.dll
    >
    >
    > However, if I navigate to that directory separately PS has no trouble
    > giving me the desired information
    >
    > PS C:\> cd MSOCache
    > PS C:\MSOCache> ls -Fi msvcr90* -R | fl
    >
    >
    > Directory: C:\MSOCache\All Users\{20140000-0115-0409-1000-0000000FF1CE}-C
    >
    > Does anybody have some explanation for this as something that I should
    > be aware of and watch out for? Any workaround? It looks like something
    > is wrong with the implementation of the -Recurse option which would make
    > this technique seem unreliable.
    >
    > <help>
    > DESCRIPTION
    > The Get-ChildItem cmdlet gets the items in one or more specified
    > locations. If the item is a container, it gets the items inside the
    > container, known as child items. You can use the Recurse parameter to
    > get items in all child containers.
    > </help>
    >
    >
    > Oh. -Force finds it but that seems unnecessary. E.g. dir finds it
    > without the /a switch:
    >
    > C:\>dir/b/s/p msvcr9*
    > C:\MSOCache\All Users\{20140000-0115-0409-1000-0000000FF1CE}-C\msvcr90.dll
    >
    > PS C:\> icacls MSOCache
    > MSOCache NT AUTHORITY\SYSTEMOI)(CI)(F)
    > BUILTIN\AdministratorsOI)(CI)(F)
    >
    >
    > *and* then much of the elegance of the technique is lost in a hail of
    > "Accessed...denied" messages as other really inaccessible directories
    > (to an Administrator?) are tested and the failure of those tests
    > reported. ; ]
    >
    >
    > So it looks like -Recurse is the analog of the dir/s and -Force is a
    > (verbose!) analog of dir/a? Now all I need I suppose is to find
    > -NoVerbose option so the dir/a/s/p complete analog will be ls -Fo -R
    > -NoV | more. It may take some time before I am used to typing that in
    > hurry. And that still leaves discovering how to get a dir/b effect too. ; )
    >
    >
    > TIA
    >
    > Robert Aldwinckle
    > ---

      My System SpecsSystem Spec

  3. #3


    Tom Walker Guest

    Re: Discrepancy with ls -R ?

    "Robert Aldwinckle" <robald@newsgroup> wrote in message
    news:#P#64Qi7KHA.1424@newsgroup

    > I'm trying to use Powershell more often when I would normally be using
    > cmd.
    >
    > Today I wanted to expand the information that this cmd command gives:
    >
    > dir/a/b/s/p msvcr90*
    >
    > so I tried this in Powershell (on W7 X64 as an Admin ICIM):
    >
    > PS C:\> ls -Fi msvcr90* -R | fl | more
    >
    > I love the extra detail that that provides but am disturbed to see that it
    > completely misses an instance of the target file here:
    >
    > Oh. -Force finds it but that seems unnecessary. E.g. dir finds it
    > without the /a switch:
    The MSOCache folder has the hidden attribute. That's why you need the -Force
    parameter.



      My System SpecsSystem Spec

Discrepancy with ls -R ? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Used disk space discrepancy zipswich General Discussion 3 06 Dec 2009
DataContract size discrepancy ryanpeters74 Indigo 0 07 Apr 2008
Memory discrepancy Jim Mehl Vista General 3 30 Mar 2008
LAN driver discrepancy Rojo Habe Vista hardware & devices 3 23 Jan 2008
Discrepancy in updaes and when will the next update be? Dan Live Folder Share 1 17 Nov 2007