-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Josef Lowder wrote: > 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/' > > $ cat add_line_numbers #!/bin/bash let a=1 while read input_line do echo $a'>'$input_line let a=a+1 done add_line_numbers < input_file - -- KevinO -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFDLavII3MJ/OwKti0RAt+gAJ0R/RcpHqNPOJ9scjToLtvKK/V0aACePcmm BxLBFcX4qewzipdCH+J5NWo= =tk2z -----END PGP SIGNATURE----- --------------------------------------------------- PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us To subscribe, unsubscribe, or to change you mail settings: http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss