How to insert an incremented line count?

トップ ページ
添付ファイル:
Eメールのメッセージ
+ (text/plain)
このメッセージを削除
このメッセージに返信
著者: Josef Lowder
日付:  
To: PLUG
題目: How to insert an incremented line count?

How can one insert an incremented line count number
at the beginning of every line of a text file?

A shell script that I had on my old unix system used to do
something like this, but I can't get it to work on my current
linux system.

# increment - increments line-sequence numbers

grep -v "=" $1 ^
grep -n '^' ^
sed 's/^\([1-9]\):\(.*\)/000\1:\2/
s/^\([1-9][0-9]\):\(.*\)/00\1:\2/
s/^\([1-9][0-9][0-9]\):\(.*\)/0\1:\2/
s/^\([0-9][0-9][0-9][0-9]\):\(.*\)\.\([0-9][0-9][0-9][0-9]\)\(.*\)/\2\.\1\4/'


---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss