ls

Table of Contents

Lists the contents of specified remote directory.

Syntax

ls [ <directory> ]/[ <wildcard> ]

Remarks

Lists the contents of specified remote directory. If directory is not specified, lists working directory. When wildcard1) is specified, it is treated as set of files to list. Otherwise, all files are listed.

Advertisements:

Alias: dir

XML log element: ls

Examples

ls *.html
ls /home/martin
ls

Converting to .NET Assembly

When converting script to .NET Assembly, map ls command to Session.ListDirectory method and print returned RemoteDirectoryInfo in your preferred format.

Parameters mapping: Command parameter directory/wildcard maps to method parameter path. You have to convert relative path to absolute path.

For example, following script snippet:

cd /home/martinp
ls

maps to following PowerShell code:

$directory = $session.ListDirectory("/home/martinp")
 
foreach ($fileInfo in $directory.Files)
{
    Write-Host ("{0}{1} {2,9} {3,-12:MMM dd HH:mm:ss yyyy} {4}" -f
        $fileInfo.FileType, $fileInfo.FilePermissions, $fileInfo.Length,
        $fileInfo.LastWriteTime, $fileInfo.Name)
}

Note that this omits inode, owner and group as these are not available in .NET assembly.

1) Windows wildcard supports * and ? only. It does not support all the features of file masks.
 
  scriptcommand_ls.txt · Last modified: 15 May 2013 by prikryl
 

Search Documentation

This page

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

Associations

Kyplex Cloud Security Seal - Click for Verification

Site design by Black Gate