Thread View: comp.editors
7 messages
7 total messages
Started by Arnzie
Sat, 19 Sep 1998 00:00
Adding Line Numbers to a text file
Author: Arnzie
Date: Sat, 19 Sep 1998 00:00
Date: Sat, 19 Sep 1998 00:00
20 lines
1482 bytes
1482 bytes
Hi, I was wondering if anybody could tell me where I could find a program which prints line numbers. I have a text file with the code from a program I made in Borland JBuilder, and I want to add line numbers to the start for easy reference. If anybody knows of such a program, could they please email me at mkarnel@ballarat.starway.net.au Any help I recieve will be much appreciated. Thank you Adam Arnel -- ----------- Adam Arnel EMAIL : mkarnel@ballarat.starway.net.au WEBPAGE : http://www.ballarat.starway.net.au/~mkarnel ICQ : 2067609
Re: Adding Line Numbers to a text file
Author: Dominic Mitchell
Date: Mon, 21 Sep 1998 00:00
Date: Mon, 21 Sep 1998 00:00
18 lines
1837 bytes
1837 bytes
In comp.text, Arnzie <mkarnel@ballarat.starway.net.au> wrote:
>Hi, I was wondering if anybody could tell me where I could find a program
>which prints line numbers.
>I have a text file with the code from a program I made in Borland JBuilder,
>and I want to add line numbers to the start
>for easy reference. If anybody knows of such a program, could they please
>email me at mkarnel@ballarat.starway.net.au
If your Unix has it, you can use the nl(1) utility. Otherwise, some
versions of cat(1) can do line numbering for you. Failing all that, try
using a little awk(1) script along the lines of:
$ awk '{print NR, $0}' file > newfile
--
Dom Mitchell -- Palmer & Harvey McLane -- Unix Systems Administrator
"Xerox studies suggest that most people print out electronic mail
that is longer than half a page; paper use rises by 40 percent in
offices that introduce E-mail." -- CCM
Re: Adding Line Numbers to a text file
Author: Fred Smith
Date: Mon, 21 Sep 1998 00:00
Date: Mon, 21 Sep 1998 00:00
24 lines
1957 bytes
1957 bytes
Dominic Mitchell (dom@phmit.demon.co.uk) wrote:
: In comp.text, Arnzie <mkarnel@ballarat.starway.net.au> wrote:
: >Hi, I was wondering if anybody could tell me where I could find a program
: >which prints line numbers.
: >I have a text file with the code from a program I made in Borland JBuilder,
: >and I want to add line numbers to the start
: >for easy reference. If anybody knows of such a program, could they please
: >email me at mkarnel@ballarat.starway.net.au
: If your Unix has it, you can use the nl(1) utility. Otherwise, some
: versions of cat(1) can do line numbering for you. Failing all that, try
: using a little awk(1) script along the lines of:
Or if you have a grep utility:
grep -n '^.*$' infile > outfile
Fred
--
---- Fred Smith -- fredex@fcshome.stoneham.ma.us -----------------------------
"For the word of God is living and active. Sharper than any double-edged
sword, it penetrates even to dividing soul and spirit, joints and marrow;
it judges the thoughts and attitudes of the heart."
---------------------------- Hebrews 4:12 (niv) ------------------------------
Re: Adding Line Numbers to a text file
Author: Moshe Zadka
Date: Tue, 22 Sep 1998 00:00
Date: Tue, 22 Sep 1998 00:00
59 lines
2264 bytes
2264 bytes
On 21 Sep 1998, Gabor wrote:
> In comp.editors, Arnzie <mkarnel@ballarat.starway.net.au> wrote :
> # Hi, I was wondering if anybody could tell me where I could find a program
> # which prints line numbers.
> # I have a text file with the code from a program I made in Borland JBuilder,
> # and I want to add line numbers to the start
> # for easy reference. If anybody knows of such a program, could they please
> # email me at mkarnel@ballarat.starway.net.au
> # Any help I recieve will be much appreciated.
> #
> # Thank you
> # Adam Arnel
>
> cat -n <file>
Or, with perl
----- Cut here -----
#!/usr/bin/perl -w
use strict;
my $i=1;
while(<>) {
print $i++, " ", $_;
}
----- Cut here -----
Or, in C
----- Cut here -----
#include <stdio.h>
int main(int argc, char **argv)
{
int i=1;
int c;
printf("%10d ", i++);
while((c=getc(stdin))!=EOF) {
putc(c, stdout);
if(c=='\n') {
printf("%10d ", i++);
}
}
}
----- Cut here --------
Or with awk
----- Cut here --------
#!/usr/bin/awk -f
{print NR, $0}
----- Cut here --------
Which do you prefer?
--
Moshe Zadka <moshez@math.huji.ac.il> | (\_/)
What's Yellow and Complete?A Bananach Space|( =(^Y^)=
Being smart means being able to count to 20| \_(m___m)
without taking off your shoes - Micky Mouse|(originally by jgs)
Re: Adding Line Numbers to a text file
Author: William Park
Date: Tue, 22 Sep 1998 00:00
Date: Tue, 22 Sep 1998 00:00
14 lines
1299 bytes
1299 bytes
Arnzie (mkarnel@ballarat.starway.net.au) wrote: : Hi, I was wondering if anybody could tell me where I could find a program : which prints line numbers. : I have a text file with the code from a program I made in Borland JBuilder, : and I want to add line numbers to the start : for easy reference. If anybody knows of such a program, could they please : email me at mkarnel@ballarat.starway.net.au : Any help I recieve will be much appreciated. : Thank you : Adam Arnel 'cat -n' will number each line. --
Re: Adding Line Numbers to a text file
Author: Al Aab
Date: Wed, 23 Sep 1998 00:00
Date: Wed, 23 Sep 1998 00:00
133 lines
5583 bytes
5583 bytes
1- cat -n
2- ln
3- DOS norton utilities lp (line printer w options)
4- sed onliner by al aab (more flixible, if u know sed)
see oneliners in:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SED RESOURCES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
to master regular expressions
to master sed
join my seders informal email list :
af137@torfree.net
----
sed web pages
"sed one liners" by Eric Pement
"Doing It with sed" by sed stud Carlos
http://seders.icheme.org/ seders grab bag (seders official web page)
http://www.dbnet.ece.ntua.gr/~george/#seders seder, engineer, Dr2b Yiorgos
THE SED FAQ
latest version of the sed FAQ is usually at:
http://seders.icheme.org/tutorials/sed_faq.txt
http://www.dbnet.ece.ntua.gr/~george/sed/sedfaq.html
http://www.ptug.org/sed/sedfaq.html
http://www.cornerstonemag.com/sed/sedfaq.html
----
http://www.math.fu-berlin.de/~guckes/sed/ seder Herr Guckes
http://www.math.fu-berlin.de/~leitner/sed/ Herr Leitner
http://www.ptug.org/sed/custom_sed.html supersed writer, seder Simon Taylor
http://www.cis.nctu.edu.tw/~gis84806/sed exotic scripts.seder Yao-Jen Chang
sed/regular expressions tutorials/refs
1- http://www.dordt.edu:457/OSUserG/BOOKCHAPTER-14.html
Chapter 14, Manipulating text with sed
2- "Doing It with sed" by sed stud Carlos (see http's above)
3- SunOS Manual Pages
http://www.intac.com/man/sunos/sed.1v.html
http://cmgm.stanford.edu/man2html/sed.1v.html
4- u-sedit2. has nice sed docs.
http://wuarchive.wustl.edu/systems/ibmpc/garbo.uwasa.fi/editor/u-sedit2.zip
5- dc UNIX stack-calculator, in sed, by sed stud GREG UBBEN
http://www.dbnet.ece.ntua.gr/~george/sed/dc.sed.html
6- sierpinski gasket/triangle, in sed, by sed stud KEN PIZZINI
posted by Al Aab, in July 1998 to
alt.comp.editors.batch & comp.unix.shell
search dejanews
----
some sed implementaions
"official" release of GNU sed-3.01 is finally available from:
ftp://ftp.gnu.org/pub/gnu/sed-3.01.tar.gz
sedmod.zip very extended/awkish DOS sed
ftp://ftp.adam.anet.cz/pub/cdrom3/fileutil/sedmod.zip
http://www.ptug.org/sed/SEDMOD10.ZIP
MKS Toolkit, windows 32 http://www.mks.com
ftp://uiarchive.uiuc.edu/pub/systems/pc/simtelnet/win95/util/
ud32_v43.zip B 3381699 980512 UnixDos: Full Unix set: 65 progs +28 new
utils
ftp://uiarchive.uiuc.edu/pub/systems/pc/simtelnet/win3/util/
ud16_v42.zip B 4767550 980313 UnixDos: Full Unix set. 64 progs +28 new
utils
----
my favourite DOS/UNIX sed :
ftp://uiarchive.uiuc.edu/pub/systems/pc/simtelnet/msdos/txtutl/sed15.zip
ftp://uiarchive.uiuc.edu/pub/systems/pc/simtelnet/msdos/txtutl/sed15x.zip
Directory: /pub/systems/pc/simtelnet/msdos/txtutl/
Filename Type Length Date Description
sed15.zip B 62082 910930 Unix-compatible streaming editor v1.5 TC src
sed15x.zip B 20300 910930 Unix-compatible streaming editor v1.5 EXE/docs
sed15.zip has C source, compilable for UNIX.
sed15.exe compiled with mingw32 for 32bit environments at:
http://www.dbnet.ece.ntua.gr/~george/sed/sed15.exe
----
sed/batch/text newsgroup:
alt.comp.editors.batch
if your newsfeed does not carry it, search dejanews.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
William Park (cv601@torfree.net) wrote:
: Arnzie (mkarnel@ballarat.starway.net.au) wrote:
: : Hi, I was wondering if anybody could tell me where I could find a program
: : which prints line numbers.
: : I have a text file with the code from a program I made in Borland JBuilder,
: : and I want to add line numbers to the start
: : for easy reference. If anybody knows of such a program, could they please
: : email me at mkarnel@ballarat.starway.net.au
: : Any help I recieve will be much appreciated.
: : Thank you
: : Adam Arnel
: 'cat -n' will number each line.
: --
--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator sed u soon
it is not zat we do not see the s o l u t i o n
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
Re: Adding Line Numbers to a text file
Author: Eric Pement
Date: Wed, 23 Sep 1998 00:00
Date: Wed, 23 Sep 1998 00:00
22 lines
1547 bytes
1547 bytes
On Sat, 19 Sep 1998 22:15:25 +1000, "Arnzie" <mkarnel@ballarat.starway.net.au> wrote: >Hi, I was wondering if anybody could tell me where I could find a program >which prints line numbers. Download this file (about 830k) of the Unix text utilities: ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/txt122b.zip These are the standard suite of GNU text utilities ported to MS-DOS. You'll find that nl.exe is a flexible, powerful program for numbering lines -- that's all it's intended to do. You can also number lines with "cat.exe -n filename", but nl has more options. Eric Pement -- Eric Pement <epement@jpusa.chi.il.us> senior editor, Cornerstone magazine http://www.cornerstonemag.com 939 W. Wilson Ave., Chicago, IL 60640-5706 tel: 773/561-2450, 1-(ext.)2084 fax: 773/989-2076
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads