HDTenEightyP/NetNews huggingface dataset:
From: dattier@ddsw1.mcs.com (DWT)
Subject: Re: Getting the nth line of a file
Date: Wed, 27 Jan 1993 15:53:27 GMT
Organization: Contributor Account at ddsw1, Chicago, Illinois  60657

aaron@atlantis.uucp wrote in <1993Jan26.151133.18029@atlantis.uucp>:

| I wrote:
| : Is there an easy, elegant, and quick way to get the Nth line of a file in
| : UNIX?  Or, failing that, in C?
| 
| : Currently I use the simple, but somewhat slow:
| 
| : head -n | tail -1
| 
| I received several email replies, which I will summarize here.

... etc.

Several people suggested

sed -n __p file

where "__" is a decimal numeral for the desired line number.  sed __!d file
is equivalent (and shorter to write, but escape the bang if you use *csh).

The following should be somewhat faster, as it quits after printing the __th
line instead of reading and discarding the rest of the input:

sed -n '__{
p
q
}' file

where again "__" is a numeral for the desired line number's position.  You
can put the numeral outside the quotes or use weak quotes instead in case
you'd like to use a variable there.

In some later seds it can be condensed to this:

sed '__{p;q;}' file

David W. Tamkin   Box 59297   Northtown Station, Illinois  60659-0297
dattier@ddsw1.mcs.com    CompuServe: 73720,1570    MCI Mail: 426-1818
From: dmp@cs.bham.ac.uk (Donald Peterson)
Newsgroups: comp.unix.questions
Subject: sed and email addresses
Date: 20 Jan 93 13:55:01 GMT
Organization: Cognitive Science, Birmingham, UK


I need to use a stream editor (eg sed or awk) to extract email
addresses from accumulated email. Using fgrep I get lines like

	From: person's name <person@address>

and

	From: person@address (person's name)

etc.

Can anyone tell me what is the sed or awk command for "pick out the
string with SPACE, < or ( at the left, @ in the middle, and SPACE, >
or ) in the right, no SPACEs in between?

Please email me direct:

Thanks,

Donald Peterson.

email: D.M.Peterson@cs.bham.ac.uk
From: pford@deepthought.unm.edu (Paul E. Ford)
Newsgroups: comp.unix.questions
Subject: Need TERMCAP entry for Tandy 1100 FD
Date: 26 Jan 1993 01:28:00 GMT
Organization: Society for a Saner Hamlet
Distribution: world
NNTP-Posting-Host: deepthought.unm.edu
Keywords: Tandy 1100 FD  TERMCAP


A friend of mine bought a Tandy 1100 FD not long ago and asked
me to help her set it up to dial up the university.  Unfortunately
we have yet to find a termcap entry which works well with the
machine and telecom package.  We are using Deskmate's built-in
telecom package and have tried most of the *reasonable* termcap
entries I could find which might work (vt100, ansi, ibmpc, trs80,
trs2, trs100), to no avail.  Any help would be greatly appreciated,
and responses via email are preferred so as not to bother the net as
a whole with a trivial matter.

thank you

Paul
-- 
pford@math.unm.edu (Paul E. Ford  -- CS Grad Student)
alt.peeves official "Player of Bit Parts" and "Yes Man"
"You just wanna see me drag my hooters through my barbeque..."
	--Booter on Dan's suggestion to lean forward when eating
Newsgroups: comp.unix.questions
From: eric@vistachrome.com (Eric Brunson)
Subject: Re: So what _is_ so good about vi?
Organization: Vista-Chrome, Inc.
Date: Mon, 25 Jan 1993 14:34:38 GMT

woods@robohack.UUCP (Greg A. Woods) writes:

>In article <7245@m1.cs.man.ac.uk> murphy@vtx.ma.man.ac.uk (Malcolm Murphy) writes:
>> Personally, I prefer vi to Emacs because
>> 
>> 1.  The command sequences that I use a lot are easier to remember
>Matter of opinion, I've found....
>> 2.  I don't really need everything that emacs has
>Maybe not today....
>> 3.  Things I need like special configurations for TeX, fortran, shell scripts etc
>>     I can do myself and I know _exactly_ what they are going to do
>So turn off all the magic -- ah sorry, "electric" modes.
>> 4.  I like being rebellious - everyone else uses emacs :-)
>I wish!  :-)
>> If you ask me, emacs is TOO clever.  Now, micro-emacs is a different matter, but
>> they don't have that here....   (boo)
>Whoa!  Wait a minute here.  If you're talking about small emacs
>"clones" in general, then I think you're looking at things wrong.  The
>real benefit of emacs is that it's so maleable.  The "micro" clones
>usually lack an integral extension language, and are only of an
>advantage where "the real thing" is not usable.
>BTW, I'm not a fan of the "Microemacs", and I seriously suggest you
>look at some of the other clones, such as my favorite, Jove.
>-- 
>						Greg A. Woods

Uh oh... Let me point out two truths in life.  
1) Opinions are like noses, everybody has one, and no one wants to 
   pick someone elses.
2) Never, never, never, never, never, never, never, ever criticize emacs
   to an emacs user.
My nose, I mean opinion, is that it's silly to say that this is better
than that and think that everyone is going to agree.  Different things
are right for different people.  If I have a choice I do all my text
editing on the Mac in the MPW editor.  If I have no choice under Unix 
I usually end up using vi, for the simple fact that the times that I don't 
have the choice are the times that the damn computer is down and I'm 
editing fstabs and mounttabs and am stuck with the built in tools ( I can
also hobble along in ed or e if I have to ).  The key here is that anyone
doing real hard core system support had better be able to get along with
whatever is available.  

When the going gets tough, the tough say:

                 'echo "/dev/sd0a / 4.2 rw 1 1" > /etc/fstab'

P.S.
Please... not another flame war over vi and emacs.

-- 
 ------------------------------
| | Dear Auntie Em,            |     Eric Brunson
|o|    I hate Kansas.  I hate  |     eric@vistachrome.com
| |    the farm.  I hate you.  |     brunson@math.fsu.edu
Newsgroups: comp.unix.questions
From: Stephen.Urquhart@launchpad.unc.edu (Stephen Urquhart)
Subject: printer redirection (to printer on bwlpr)
Organization: University of North Carolina Extended Bulletin Board Service
Date: Sat, 23 Jan 1993 21:56:41 GMT

	I am looking for some sort of dynamic printer redirection utility,
such that I can print (from unix) to  a printer attached to a pc running
a tcp-ip spooler. Since the unix box I'm on is over regulated and understaffed,
it is highly unlikely that I can get something set up "offically" through 
/etc/printcap..  Even if the set up involves more "offical" sanction, I 
would be interested - a sys admin I queried expressed interest in
such a utility.

	If you wish to send me an email response, I have only one request.
This bbs's mailer is unreliable due to disk space problems, so please
use this address: urquhart@mcmail.cis.mcmaster.ca

Thanks,
Stephen
--
   The opinions expressed are not necessarily those of the University of
     North Carolina at Chapel Hill, the Campus Office for Information
        Technology, or the Experimental Bulletin Board Service.
           internet:  laUNChpad.unc.edu or 152.2.22.80
Xref: sparky comp.unix.questions:16056 comp.unix.programmer:6081
From: cq377@cleveland.Freenet.Edu (David C. Williss)
Newsgroups: comp.unix.questions,comp.unix.programmer
Subject: Re: Segmentation fault in malloc()
Date: 29 Jan 1993 03:55:20 GMT
Organization: Case Western Reserve University, Cleveland, OH (USA)
Reply-To: cq377@cleveland.Freenet.Edu (David C. Williss)
NNTP-Posting-Host: hela.ins.cwru.edu


In a previous article, tm8t+@andrew.cmu.edu (Tod McQuillin) says:

>jacobsen@itexjct.jct.ac.il (Joel Jacobsen) writes:
>>  I wrote a program which use fgets to read a line from a file.
>> one of the functions get a segmentation fault in the line:
>> 
>>     fgets(str,160,file);
>> 
>> when :  char *str;
>>         FILE *file;
>> 
>> 
>>  The frame stack in gdb show:
>> 
>>     (gdb) where
>>     #0 0xf7734634 in malloc ()
>>     #1 0xf7733bf0 in _findbuf ()
>>     #2 0xf773b86c in _filbuf ()
>>     #3 0xf773df40 in fgets ()
>>     #4 0x2288 in choose_from_list () at m.c:81
>> 
>>  What might be the problem?
>
>Almost certainly you went past the end of one of the memory blocks
>given to you by malloc, thus stomping on some pointers malloc uses
>internally.  This is the first thing I check for when I get a segfault
>in malloc(), and to date it has never been anything else.
>
I've had the same problem, with the same answer.  Darn hard to find
too, as it'll never give a segmentation fault where you're clobbering
it, just the next time you try to malloc.  
-- 
		-Dave Williss
---------------------------------------------------------------------------
Standards are great!  Everybody should have one of their own!
The opinions stated above are Mine!  All Mine!  You can't have them.
Newsgroups: comp.unix.questions
From: zzsb@kursix.rrzn.uni-hannover.de (Wolfgang Sander-Beuermann)
Subject: Re: Using 'talk'
Organization: RRZN
X-Newsreader: Tin 1.1 PL4
Date: Thu, 28 Jan 1993 07:22:21 GMT

>I;ve been using 'talk'to converse with a few friends.  But sometimes,
>when I try to signal a couple of people I get "checking for invitation
>on caller's machine."  That message just stays on the screen for the
>longest time and I never get any connection.  Can anybody tell me why this
>happens and what to do about it.  Thanks in advance.

If you get that message, it means your talk demon tries to connect to
another one, he can't talk to.  Usually that happens, if your system
uses the <ntalk> (n for *new* talk) version, and the other system uses the
older <talk>. SUN's usually use <talk>, the rest of the world (sure there
are exceptions) use <ntalk>. It's really a pitty, that the two are not
compatible, I've run into the same problem very often.

Wolfgang Sander-Beuermann           zzsb@kursix.rrzn.uni-hannover.de
From: ashok@ttivision1.tamu.edu (ashok rao)
Newsgroups: comp.unix.questions
Subject: Help with getrusage() command.
Date: 28 Jan 1993 05:41:02 GMT
Organization: Texas Transportation Institute
Distribution: usa
NNTP-Posting-Host: ttivision1.tamu.edu


hi folks,

        I need to use getrusage() to find how long it
        takes for a certain segment of code to run.

        getrusage(--

        CODE HERE

        getrusage(--

        
        I'd like to know if any one has done this or if this
        is the right way to find the time for the certain code.

        Proven answers are welcome.

thanks
arao
ashok@ttivision1.tamu.edu
Newsgroups: comp.unix.questions
From: twpierce@unix.amherst.edu (Tim Pierce)
Subject: Re: Getting the nth line of a file
Organization: Elitist Usenet Administrators, Stuff and Nonsense Division
Date: Wed, 27 Jan 1993 05:18:54 GMT

In article <1993Jan26.232708.10878@odin.corp.sgi.com> vidya@akshay.csd.sgi.com (Vidya Alankar) writes:

>In article <1993Jan26.151133.18029@atlantis.uucp>, aaron@atlantis.uucp writes:
>
>|> > I'm not sure if
>|> > sed quits after printing the Nth line, which is really what you want
>|> > for speed; the sed man page always confuses me.

The sed man page isn't really that bad.  Just keep remembering Indiana
Jones: "Only the penitent will pass."

>It does read the full file. I do not know enough about sed to say if they
>is a way to stop after the Nth line. The awk command above does just this.

sed -n 'Npq' (where N is the number of the line to print).

This is infinitely more desirable than any of the other sed solutions
listed.  Since the command contains no metacharacters or spaces, I
doubt you need quotes.

-- 
____ Tim Pierce                / 
\  / twpierce@unix.amherst.edu /               Rocks say goodbye.
 \/ (BITnet: TWPIERCE@AMHERST) / 
Newsgroups: comp.unix.questions
From: jdell@nefertiti.mit.edu (John Ellithorpe)
Subject: Re: Simple scripting questions
Followup-To: comp.unix.questions
Organization: Massachusetts Institute of Technology
Date: Sat, 23 Jan 1993 17:25:11 GMT

On Fri, 22 Jan 93 21:25:13 GMT, dremsen@mbl.edu (David Remsen) said:
> Followup-To: comp.unix.questions

> I am trying to make a little shell script for a phone directory file.  I
> want
> to be able to ask the user for a string to search for and the field to
> search.
> The phone file is a comma delimited file so I want to use awk to
> search a particular field.

> I assign the search input to a variable called find.  The problem is that
> awk doesnt seem to be able to deal with this variable.

> awk -F: '$1 ~ /John/' phone.dat         - will work
> awk -F: '$1 ~ ${find}' phone.dat          - will not work

> Can someone tell me why.  Ive tried all different permutations.  

I've run into this problem before.  The reason you are having problems is that
you are confusing shell variables and awk variables.  Inside the single
quotes, awk does treat ${find} as a shell variable.  The solution I've found
(from the net of course) was:

	awk -F: '$1 ~ /'$find'/' phone.dat

The extra single quotes lets $find be seen by the shell (since it's not
embedded in single quotes) and expanded before awk is executed.  The other
way to do it is to use awk variables, but I've found the above method easier.

John
--

===============================================================================
John Ellithorpe                           | Internet: jdell@maggie.mit.edu
Dept. of Physics, Rm 26-349               | Phone   : (617) 253-3074  Office
Massachusetts Institute of Technology     |           (617) 253-3072  Lab
Cambridge, MA  02139                      |           (617) 236-4910  Home
===============================================================================
From: silvers3@husc8.harvard.edu (Jolyon Silversmith)
Newsgroups: comp.unix.questions
Subject: Help: Improperly Named File
Date: 27 Jan 93 15:23:01 GMT
Organization: Harvard University Science Center

Line noise resulted in a file being named "download{{{[w3v3{" and now it can't
be accessed by cat, mv, vi, etc; (I presume because some of the characters are
wildcars themselves, but even using quotation marks with mv doesn't help). Any
ideas on what to do? E-mail preferred. Thanks.

-- 
Jolyon A. Silversmith __________________________________________________________
Mather House 100             Director: Civil Liberties     These opinions aren't
Cambridge, MA 02138          Union of Harvard  College     necessarily  those of
silvers3@husc.harvard.edu ________________________________ CLUH.  But who knows?
Newsgroups: comp.unix.questions
From: lfm54477@uxa.cso.uiuc.edu (Libor F. Michalek)
Subject: Please post Hardware buyers guide
Organization: University of Illinois at Urbana
Date: Fri, 22 Jan 1993 01:04:01 GMT

 am about to buy a 486 33Mhz EISA motherboard. I am running AT&T UNIX.   
I was wondering what would be the best brand to get. Also are VL-bus
motherboards a viable alternative and if so what are the perfomance
gains/losses. Finally do EISA motherboards require different types of SIMM's
then ISA motherboards? any input on EISA motherboards would be helpful
Thank You

Libor.
email   libor@ncsa.uiuc.edu
From: peter@dragon.acadiau.ca (Peter Steele)
Newsgroups: comp.unix.questions
Subject: Re: replacement for vi
Date: 23 Jan 93 16:09:10 GMT
Organization: Acadia University

>I know many folks who've used GNU emacs and gone back to vi.  These are
>world-class programmers who have legitimate reasons for their choices.  
>Be not so quick to discredit your betters.

I have a guy working for me who said he gave emacs a three month trial
and ended up going back to vi. He said he found emacs slow, and could
ultimately get more productivity out of vi....
-- 
Peter Steele        Unix Services Manager            peter.steele@acadiau.ca 
Acadia Univ., Wolfville, NS, Canada B0P 1X0  902-542-2201  Fax: 902-542-4364
Newsgroups: comp.unix.questions
From: amay3@mach1.wlu.ca (andrew may)
Subject: Intercepting talk
X-Newsreader: TIN [version 1.1 PL6]
Organization: Wilfrid Laurier University
Date: Sun, 24 Jan 1993 04:50:45 GMT
Keywords: talk

I would like to know how to intercept the message from the talk daemon
saying that somebody wants to talk. I want to allow one of my programs to
receive that information and tell me in a better way that somebody wants to
talk to me. Anybody have any idea how to do this?

Thanks.
******************************************************************************
* Andrew May         *                                    This  .sig hidden  *
* amay3@mach1.wlu.ca *                                   behind an SEP field *
******************************************************************************
Newsgroups: comp.unix.questions
From: jhgreen@cs.sandia.gov (Jethro H. Greene)
Subject: How do you print a character given its ASCII number?
Originator: jhgreen@cs.sandia.gov
Organization: Sandia National Laboratories, Albuquerque, NM
Date: Fri, 15 Jan 93 03:47:44 GMT

Given an ASCII number (dec, hex, or oct) how would I print that particular
character?  Also are there any problems with the NULL char.?

Thanks in advance.

-- 
Jethro H. Greene
Massively Parallel Computing Research Laboratory,
Sandia National Laboratories, Albuquerque, New Mexico
From: srinivasan@vax1.umkc.edu
Newsgroups: comp.unix.questions
Subject: question on fscanf
Date: 23 Jan 93 00:07:30 GMT
Organization: University of Missouri - Kansas City
NNTP-Posting-Host: vax1.umkc.edu

Hi,
	Thanks a lot for  all the people who responded to my question.
I am rephrasing the question now since i found that the fopen command
si returning a valid pointer but when i do a fscanf on the file utmp
(path = /etc/utmp) then it gives a segmentation fault. Can someone 
explain this phenemenon.

thank you

balaji
From: nixon@updike.sri.com (Tom Nixon)
Newsgroups: comp.unix.questions
Subject: Help with Make files
Summary: Novice needs help with tricky makefile
Keywords: make
Date: 26 Jan 93 19:20:22 GMT


     Can anyone help me create the following make file?  Lets say I have
two files called foo.i and bar.i.  (Actually there may be many more .i files, 
but two will suffice for now.)  The first step is to convert these .i files to
.c files.  This would be done at a unix prompt by running a script file called 
convert.sh (which only takes one .i file at a time) in the following manner:
    >> convert.sh  foo.i
    >> convert.sh  bar.i
This now gives me foo.c and bar.c.  Along with these .c files, I have another 
file called main.c (which is not created with convert.sh).  I want to compile 
all the .c files with "acc" to make foo.o, bar.o, and main.o.  Next, I would
like to link them all together with the final executable stored under the name 
"main".  Can all this be done within a nice convenient make file?  

****  Could any help on this subject please be sent directly to me at:
****         nixon@updike.sri.com                

     Thanks in advance

          Tom Nixon
Newsgroups: comp.unix.questions
From: zzsb@kursix.rrzn.uni-hannover.de (Wolfgang Sander-Beuermann)
Subject: Re: Need to login many times, but type passwd once.
Organization: RRZN
X-Newsreader: Tin 1.1 PL4
Date: Wed, 27 Jan 1993 06:37:11 GMT

>It seems to me that it would be best to discuss this issue with your
>system administrator, rather than ask the net to help you try to
>circumvent local policy. If it is indeed important, perhaps you can
>convince him/her to help you.

Just in case, you can not convince your management to use the (better)
rsh-method, here is a litlle script, which does the same thing with
telnet:

===================== Script ============================

   user=YourUsername
   passw=YourPassword
   (\
   sleep 5;\
   echo "$user";\
   sleep 10;\
   echo "$passw";\
   sleep 10;\
   echo "AnyCommand(s)";\
   sleep 5;\
   echo "exit";\
   sleep 5\
   )\
   | telnet AnyHost > tempfile 2> /dev/null

====================== Script end ========================

You may not take out the sleep 5/10 lines, they are essential; if you
have any problems with it, you might have to adjust those sleep times
to your local conditions (i.e. make them longer or shorter).

Hope that helps, Wolfgang

Wolfgang Sander-Beuermann         zzsb@kursix.rrzn.uni-hannover.de
From: lpeters@postmaster@hq.af.mil (Leslie D Peters)
Newsgroups: comp.unix.questions
Subject: Re: ksh prompt
Date: 25 Jan 93 12:55:41 GMT
Reply-To: lpeters@marge.hq.af.mil
Organization: 7th Communications Group

In article <C17DJ4.FoA@sdf.lonestar.org>, larry@sdf.lonestar.org (Larry D. Clark) writes:
|> 
|> 	Netlanders
|> 
|> 	I am using ksh on a platform running Unix 5.4 at work and would 
|> 	like to have my PS1 to reflect the current working directory.
|> 	Does any one have any ideas how to do it??
|> 
|> 	If this is a faq please tell me where to get the faq.
|> 
|> 	Thanks
|> 
|> 	Larry
|> 
|>      Larry D. Clark   larry@sdf.lonestar.org  ...!seas.smu.edu!letni!sdf!larry
|> -- 
|> Larry D. Clark   larry@sdf.lonestar.org  ...!seas.smu.edu!letni!sdf!larry
Try:
PS1='$PWD $ '
-- 
|     I haven't lost my mind --     | Les Peters, Sorceror's Apprentice |
| it's backed up on tape somewhere. |    lpeters@marge.hq.af.mil        |
From: hsiegel@cvbnet.prime.com (mailhost)
Newsgroups: comp.unix.questions
Subject: Re: Spell checker from inside vi
Date: 28 Jan 93 15:21:12 GMT

From article <1993Jan27.095737.16318@ncrcae.ColumbiaSC.NCR.COM>, by raj@grok101.ColumbiaSC.NCR.COM (0000-Admin(0000)):
> In article <1993Jan26.170105.4573@doug.cae.wisc.edu>, saunders@luther.che.wisc.edu (Brian E. Saunders) writes:
> |> In article <C1HD54.Iv@news.udel.edu> william@bach.udel.edu (Wild William) writes:
> |> >Is there a simple way to do spell checking on the current file from
> |> >inside vi?
...
> |> I can pipe the lines through spell by going to the command line and typing
> |> "1,$!spell", but unfortunately the output replaces all of your lines!  Does
> |> anybody know how to redirect the output to the bottom of the file you are
> |> currently working on?  This should be easy, but I don't know how to do it.
...
> You can try the following on the command line of vi:
> :!spell % >> %
> 
> This will append the output of the command "spell" to the eof.
> The "%" means the current file that is being edited.

Or even simpler,
	:w
	:$r!spell %
will (first) write the current version of the file to disk and then
append the output of "spell" on the current file to the end of the
file being edited.

Howard Siegel                   hsiegel@piano.prime.com
Computervision                  hsiegel@primerd.prime.com
Bedford, Mass.                  hsiegel%piano.prime.com@RELAY.CS.NET
(617) 275-1800 x4064            cvbnet!hsiegel@primerd.prime.com
From: harley@engrhub.ucsb.edu (Harley Hahn,,,HAHN,personal)
Newsgroups: comp.unix.questions
Subject: Re: stripping ^M's
Keywords: stripping,carriage returns
Date: 22 Jan 93 16:05:05 GMT

For some reason, in my posting on how to delete two ^M's from the
end of each line is a file, the one line of the posting that was
the most important -- the actual ex command -- was mysteriously
truncated.  (Things like that are always happening in California...)

The full command is:

:%s/^M^M$//

(When you enter it, type a ^V (Ctrl-V) before the each (Ctrl-M).)

The analysis of this command still holds:

You are replacing all occurrences of two ^M's at the end
of a line, with nothing:

:     --> the following is an ex command
%     --> carry out operation over all lines in the editing buffer
s     --> substitute
/     --> beginning of pattern to be replaced
^M^M  --> two ^M's
$     --> at the end of a file
/     --> beginning of replacement text
/     --> end of replacement text

Note that you do not need to add "g" to the end of the command.
A suffix of "g" is best used when the pattern to be replaced
will occur in more than one place in the line.
When you know where the pattern will be (in this case,
at the end of the line) it is best to
specify the location exactly (in this case with a "$").

Sorry for the inconvenience.

-- Harley Hahn

Postscript to certain Middle Eastern intelligence services:

The forgoing is NOT, I repeat NOT, a secret code to pass
a message to American military installations abroad.