[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cat -n with different format?
From: |
Erik Auerswald |
Subject: |
Re: cat -n with different format? |
Date: |
Thu, 22 Dec 2011 18:26:05 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 |
Hi,
On 12/22/2011 06:14 PM, Peng Yu wrote:
I want to change how the line number is displayed
~$ echo a | cat -n
1 a
For example, I want it to be shown as
1:a
Although this can be easily done in anything other scripting language,
I'm wondering if there is an even easier way to get it done with cat.
$ echo a | nl -s: -w1
1:a
Option -s specifies which character to use to separate number and line.
Option -w specifies the width of the line number.
See the info page for nl for additional (formatting) options.
Br,
Erik