Autor Beitrag
bflegel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP, Win 7, BS2000
D5
BeitragVerfasst: Do 08.09.11 12:30 
Hallo liebe Gemeinde,

ich hätte eine reine Interesse-Frage:

Ich versuche eine Reihe von Linuxkommandos per pipe mit einander zu verbinden, bin mir aber nicht sicher ob dies überhaupt möglich ist:

ausblenden Quelltext
1:
2:
ls -1 | wc -l | echo xxx Dateien vorhanden       oder 
ls -1 | grep -c ".xml" | echo xxx Dateien vorhanden


Ich möchte halt gerne die Anzahl der vorhandenen Dateien in einem Verzeichnis mit einer Echo-Ausgabe "verschönen", ohne einen Umweg über eine Hilfsdatei zu gehen.

Gibts da eine einfache Möglichkeit?

Bye bflegel


Moderiert von user profile iconChristian S.: Topic aus Sonstiges (Delphi) verschoben am Do 08.09.2011 um 14:14

_________________
I know all the jokes about my name
bflegel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP, Win 7, BS2000
D5
BeitragVerfasst: Do 08.09.11 12:59 
Ich habe jetzt eine Lösung gefunden:

ausblenden Quelltext
1:
echo -n "Vorhandene Dateien:"; ls -1 | wc -l					


Damit erhalte ich die Ausgabe:

ausblenden Quelltext
1:
Vorhandene Dateien:    6300					


Das ist ausreichend für mich.

Bye bflegel

_________________
I know all the jokes about my name
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 09.09.11 01:11 
Alternativ gäbe es folgende Varianten:

ausblenden Quelltext
1:
2:
ls -l | wc -l | xargs -I echo {} Dateien gefunden
echo `ls -l | wc -l` Dateien gefunden


Hoffe, das hilft. Erklärungen finden sich auch in der Manpage unter xargs und bash (Abschnitt Backticks).

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
bflegel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 193
Erhaltene Danke: 1

Win XP, Win 7, BS2000
D5
BeitragVerfasst: Mo 12.09.11 17:28 
Danke für die Tips - ich werde mir das mal in Ruhe ansehen.

Bye
Bflegel

_________________
I know all the jokes about my name