WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Linux, UNIX, Open Source (http://www.wcm.at/forum/forumdisplay.php?f=13)
-   -   linux-befehl gesucht (http://www.wcm.at/forum/showthread.php?t=132448)

Gizmotic 26.04.2004 03:11

linux-befehl gesucht
 
Hallo!

Mir fällt kein linux-befehl ein, mit dem ich folgendes kann:

Ich habe ein Textfile und will davon den inhalt einer bestimmten zeile ausgeben.

Also sowas wie "cat text.txt -zeile 2"
sollte von folgendem textfile nur "text2" ausgeben.

text1
text2
text3

Danke für eure hilfe!

flinx 26.04.2004 03:20

Ohne mich auszukennen:
cat -n und darauf grep?

Gizmotic 26.04.2004 12:34

Das funktioniert zwar, allerdings habe ich dann ja die Zeilennummer in der Ausgabe ... die sollte noch wegkommen ...

gibt es da keinen eigenes shell-command dafür ?

_m3 26.04.2004 13:04

Windows:
perl -n -e "$count++; if( $count == $ARGV[0]) { print $_; exit }" FILENAME ZEILENNUMMER

Linux:
perl -n -e '$count++; if( $count == $ARGV[0]) { print $_; exit }' FILENAME ZEILENNUMMER

Gizmotic 26.04.2004 13:09

Vielen Dank! Funktioniert prima!

PeterWoe 26.04.2004 15:20

Alternative:

head -zeilennr text.txt | tail -1

_m3 26.04.2004 15:51

Zitat:

Original geschrieben von PeterWoe
Alternative:

head -zeilennr text.txt | tail -1

RESPEKT! :cool:


Alle Zeitangaben in WEZ +2. Es ist jetzt 19:50 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag