Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Powershell ls

Empfohlene Antworten

Veröffentlicht

hi,

ich hoffe jemand kennt sich gut mit powershell aus, denn ich habe folgendes problem: ich möchte den ordnernamen in eine variable schreiben.

das mache ich wie folgt:

$testvar = ls

nur leider schreibt er mir den kompletten output in die variable und nicht nur den ordnernamen. der inhalt von testvar sieht nun wie folgt aus:

Directory: C:\Programme\hMailServer\Data\meinemail.bla\nagios

Mode LastWriteTime Length Name

---- ------------- ------ ----

d---- 13.07.2009 14:35 FF

Ich brauche aber eigentlich nur den Ordnernamen FF . Gibt es eine möglichkeit den output so zu verkürzen?

ich bedanke mich schoneinmal.

In etwa so?


PS C:\totalcmd> ls


    Verzeichnis: Microsoft.PowerShell.Core\FileSystem::C:\totalcmd



Mode                LastWriteTime     Length Name

----                -------------     ------ ----

d----        18.04.2009     15:13            LANGUAGE

-a---        08.08.2008     07:04      43008 CABRK.DLL

-a---        08.08.2008     07:04       7259 CGLPT9X.VXD

-a---        08.08.2008     07:04       7888 CGLPTNT.SYS

-a---        08.08.2008     00:00        977 DEFAULT.BAR

-a---        18.04.2009     15:14      21262 default.br2

-a---        08.08.2008     07:04       1272 descript.ion

-a---        08.08.2008     07:04       7680 FRERES32.DLL

-a---        08.08.2008     07:04     371478 HISTORY.TXT

-a---        08.08.2008     00:00         26 NO.BAR

-a---        08.08.2008     07:04       3464 REGISTER.RTF

-a---        08.08.2008     07:04      37888 SFXHEAD.SFX

-a---        08.08.2008     07:04       2106 SHARE_NT.EXE

-a---        08.08.2008     07:04       9235 TASTEN.TXT

...
Wird zu:

PS C:\totalcmd> $tmp = ls; foreach($file in $tmp){write-host $file}

LANGUAGE

CABRK.DLL

CGLPT9X.VXD

CGLPTNT.SYS

DEFAULT.BAR

default.br2

descript.ion

FRERES32.DLL

HISTORY.TXT

NO.BAR

REGISTER.RTF

SFXHEAD.SFX

SHARE_NT.EXE

TASTEN.TXT

...
Dann wäre

$tmp = ls; foreach($file in $tmp){ write-host $file }

eine Möglichkeit für dich.

Andererseits klang dein Beitrag nicht gerade so als würdest du damit rechnen, dass mehrere Ordner oder Dateien im Verzeichnis liegen. Wie dem auch sei, wenn es nur eine Datei gibt wird auch nur ein Dateiname ausgegeben.

Erklär doch bitte mal was du genau damit vor hast dann könnte man näher drauf eingehen.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.