HDTenEightyP/NetNews huggingface dataset:
From: calvin@wshb.csms.com ( WSHB employee)
Newsgroups: comp.unix.shell
Subject: lines in files
Keywords: help
Date: 7 Oct 92 13:39:42 GMT
Distribution: na
Organization: WSHB, Herald Broadcasting Syn., Inc., Cypress Creek, SC, USA


	Well what I would like to find out is this scenario.

	I have a file with several lines.

			FILE
			
			LINE 1
			LINE 2
			LINE 3

	There is no limit to the number of lines in this file.  Is there
  a way that I can show each line on at a time and delete the certain lines?


			FILE

			LINE 1
			LINE 3

	Thanks for the help!

-- 
...calvin@wshb.csms.com.        If it wern't for bad luck,
kamikazi"calvin"                I'd have no luck at all! 
>From a warped mind comes a warped product.
These are not my employers opinions.  In fact I don't know if there mine!
Newsgroups: comp.unix.shell
From: dattier@ddsw1.mcs.com (DWT)
Subject: Re: ksh: autoloading aliases?
Date: Fri, 16 Oct 1992 03:20:45 GMT
Organization: Contributor Account at ddsw1, Chicago, Illinois  60657

lvirden@cas.org (Larry W. Virden) wrote in <1992Oct12.151610.973@cas.org>:

| anyone figured out a way to use the function autoloading capability to load
| aliases as well?

My first guess worked fine.

| I have long lists of various aliases which I wish I could just stick into
| the function directory and would autoload when I needed them but would
| stay out of the way otherwise...

OK ... say we're aliasing virden to ls -xF.

yourPS1here>  cat $functiondir/virden
virden () {
ls -xF "$@"
unset -f virden
alias virden="ls -xF"
}
yourPS1here> 

That worked fine for me under Dell SVR4 4.0's ksh 11/16/88d here on ddsw1.
You don't even have to unset -f the function name, because aliases precede
functions in interpretation order, unless you are hot to save RAM.

This worked too:

yourPS1here>  cat $functiondir/virden
virden () {
unset -f virden
alias virden="ls -xF"
virden "$@"
}
yourPS1here> 

However, that version needed the unset -f, or it would abort with "recursion
too deep" on the first call; it would work on the second call.

You could always just have an autoloading function whose definition ends in
an operation on "$@" and not use an alias at all.  Is there some reason you
can't use a function and must use an alias?

David W. Tamkin   Box 59297   Northtown Station, Illinois  60659-0297
dattier@ddsw1.mcs.com    CompuServe: 73720,1570    MCI Mail: 426-1818
From: jrichter@sinix.UUCP (Juergen Richter)
Newsgroups: comp.unix.shell
Subject: trap/sh -e question
Date: 7 Oct 92 14:48:49 GMT
Organization: SNI AG Muenchen, STO XS

Can anyone explain to me according to which rules 
1. "echo $?" will be called and
2. what "echo $?" will output in the following script:

  #!/bin/sh -e
  trap 'echo $? ; exit' 0
  ...
  trap 0

I have difficulties to see the rules due to the following cases for "..." 
(script is called "ttt"):

...		output				exit status of ...
==============================================================================
[ ]		<none>				1
------------------------------------------------------------------------------
( [ ] )		1				1
------------------------------------------------------------------------------
unknown		./ttt: unknown: not found	1
		0
------------------------------------------------------------------------------
( unknown )	./ttt: unknown: not found	1
		1
------------------------------------------------------------------------------
( [ ] ) || :	<none>				0
------------------------------------------------------------------------------
( [ ] ) && :	<none>				1
------------------------------------------------------------------------------
Newsgroups: comp.unix.shell
From: lhjensen@fish.Princeton.EDU (Leif Jensen)
Subject: Re: How to calculate the Date of Easter?
Originator: news@nimaster
Organization: Princeton University
Date: Wed, 7 Oct 1992 23:35:52 GMT

In article <10801@hq.hq.af.mil> snolan@marge.hq.af.mil writes:
>	How do I calculate the exact date for Easter in any
>given year using normal unix tools (awk, ksh, sed, perl, etc)?

Below is a psc procedure that prints the day of easter for the year
given as its argument.

What?  You've never heard of psc?  psc is a Programmable Scientific
Calculator based on the program hoc from Kernighan and Pike's
"Programming in the Unix Environment".  I will probably release the
first version in another couple weeks if there is any interest, and if
there would be no legal problems.  Future versions may support arrays,
local variables in functions, and string variables, but none of these
enhancements is currently ready.  Yes, I know about bc and dc and
perl, but I think that there is a legitimate niche for psc.  Even if
there isn't I've learned an awful lot writing it.

The below function could easily be molded into a C program or perl
script.

proc easter() {
	easter_a = $1 % 19
	easter_b = $1 div 100
	easter_c = $1 % 100
	easter_d = easter_b div 4
	easter_e = easter_b % 4
	easter_f = (easter_b + 8) div 25
	easter_g = (easter_b - easter_f + 1) div 3
	easter_h = (19 * easter_a + easter_b - easter_d \
		- easter_g + 15) % 30
	easter_i = easter_c div 4
	easter_k = easter_c % 4
	easter_l = (32 + 2 * easter_e + 2 * easter_i - \
		easter_h - easter_k) % 7
	easter_m = (easter_a + 11 * easter_h + 22 * easter_l) div 451
	easter_n = (easter_h + easter_l - 7 * easter_m + 114) div 31
	easter_p = (easter_h + easter_l - 7 * easter_m + 114) % 31
	println 'Easter in ', $1, ' is on ', easter_p + 1, \
		'/', easter_n
}

--
Leif Jensen
lhjensen@phoenix.princeton.edu
From: chet@odin.ins.cwru.edu (Chet Ramey)
Newsgroups: comp.unix.shell
Subject: Re: Losing variable outside a while loop
Date: 12 Oct 1992 19:06:24 GMT
Organization: Case Western Reserve University, Cleveland, OH (USA)
NNTP-Posting-Host: odin.ins.cwru.edu

In article <1992Oct12.172333.5037@progress.com> tucker@bedford.progress.COM writes:

>cat ${TMPFILE} | while read LINE

Shell control structures such as while and for loops are run in
subshells when used with piped input or output.  These subshells
cannot modify the parent shell's environment.

Chet
-- 
``The use of history as therapy means the corruption of history as history.''
	-- Arthur Schlesinger

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu
Newsgroups: comp.unix.shell
From: root@trebor.uucp (Bob Stockler)
Subject: Re: why spaces stripped off ??
Organization: Bob Stockler
Date: Wed, 14 Oct 1992 22:37:28 GMT

minh@lis.rch.unimelb.edu.au (Minh Tran) writes:

>	echo "enter here \c"
>	read var
>	echo $var

>	at the prompt "enter here " I entered
>		e2       e2        e2
>	the output always
>		e2 e2 e2

>	it does not matter how many spaces I have left b/w e2, they are
>	stripped off somehow !!

"echo" is stripping off the spaces because its argument isn't quoted.  Try
echo "$var", and see that the parameter 'var' does, indeed, contain them.
Newsgroups: comp.unix.shell
From: palkar@tunica.eel.ufl.edu (Malhar Palkar)
Subject: How to write to stdin of tty ? 
Organization: UF EE Department
Date: Fri, 16 Oct 92 20:56:38 GMT

Hi,

I am writing a X-windows application for a software package which acts interactively. How can I send the command to the stdin of another xterm.
In other words I want to execute a commnd in one shell from another shell.

Please respond. This package is going to be tutorial.


-- 
Bye,

M A L H A R
(send e-mail @  ==>  palkar@pine.circa.ufl.edu )
[Ph :: (904) 372-1939  ]
From: jrichter@sinix.UUCP (Juergen Richter)
Newsgroups: comp.unix.shell
Subject: Re: at: current directory
Date: 7 Oct 92 13:53:51 GMT
Organization: SNI AG Muenchen, STO XS

Answer to question from Edward J. Hartnett:
My at-manpage says:
     Standard output and standard error output are mailed to  the
     user  unless  they  are  redirected  elsewhere.   The  shell
     environment variables, current directory, umask, and  ulimit
     are  retained  when  the  commands  are executed.  Open file
     descriptors, traps, and priority are lost.
So you can use relative paths.
From: johnw@johnwuu.canb.auug.org.au (John Wright)
Newsgroups: comp.unix.shell
Subject: sed & awk different between csh and sh?
Distribution: world
Date: Fri, 16 Oct 92 12:08:20 GMT
Organization: Computer Sciences of Australia
Reply-To: johnw@canb.auug.org.au

I am using HP-UX v8.00 and noticed that the following sed and awk statements
fail when used in a csh script file, but work correctly in a sh script.

The first line of the csh script has #! /bin/csh, while the first line on the
sh script just has :

Under csh, sed fails with Variable syntax.
           awk fails with Unmatched ".

Can anyone please tell me what I am doing wrong?
All variables used/referenced have been initialised in the script prior to
their use here.

/bin/sed -e "s/[ ]*$//" \
	 -e "s/	/        /g" \
	 -e "s/^$/ /" \
	 -e "s/'/''/g" < $infile > $tmpfile


/usr/bin/awk "BEGIN { printf(\"INPUT ROUTINE \n\");\
	             seqno=1;\
	            } \
		    { printf (\"'%s',%d,'%s ',NULL\n\", name, seqno, \$0);\
		     seqno += 1;\
		    } \
	      END   { printf(\"END\n\"); }" name=$routine $tmpfile > $outfile

Thanks for all your assistance.

john w.

+========================================================================+
| John Wright                    |   Standard   | Voice : +61 6 249-1871 |
| Computer Sciences of Australia |  Disclaimer  | Fax   : +61 6 253-1259 |
| johnw@canb.auug.org.au         |    Notice    | Locn  : Canberra       |
| 100032.553@compuserve.com      |   Applies    |         Australia      |
+========================================================================+
From: ernie@neumann.une.edu.au (Ernest W Bowen)
Newsgroups: comp.unix.shell
Subject: Re: How to calculate the Date of Easter?
Summary: A shell script to calculate the date of Easter
Date: 11 Oct 92 06:06:22 GMT

In article <10801@hq.hq.af.mil>, snolan@postmaster@hq.af.mil (Scott D Nolan) writes:
> Weird question:
> 
> 	How do I calculate the exact date for Easter in any
> given year using normal unix tools (awk, ksh, sed, perl, etc)?
> 
> 	Many thanks in advance.
> 
> Scott Nolan and Les Peters
> 7th CG/DOSO
> snolan@marge.hq.af.mil
> lpeters@marge.hq.af.mil


        According to H.V. Smith in "Mathematical Spectrum," 11 (1978/79),
23-24, the following rule appeared in Butcher's Ecclesiastical
Calendar, 1876.  To find the date of Easter Sunday for year y:

              Divide            by      Quotient  Remainder
        ---------------------------------------------------
                 y               19                   j
                 y              100        k          h
                 k                4        m          n
               k + 8             25        p
             k - p + 1            3        q
        19j + k - m - q + 15     30                   r
                 h                4        s          u
        32 + 2n + 2s - r - u      7                   v
           j + 11r + 22v        451        w
         r + v - 7w + 114        31        x          z

Here x is the number of the month ond 1 + z is the day of that
month upon which Easter Sunday falls in the year y. 

	The following csh shell script does these calculations and
echoes x and d = 1 + z.  Some signs appear to be wrong because in
@ assignments + and - are right-associative.

---

# With argument y, this echoes the month-number and day-number for
# Easter Sunday in year y; e.g. easter 1992 displays  4 19.
@ j = $1 % 19
@ k = $1 / 100
@ h = $1 % 100
@ m = $k / 4
@ n = $k % 4
@ p = ($k + 8) / 25
@ q = ($k - $p - 1) / 3
@ r = (19 * $j + $k - $m + $q - 15) % 30
@ s = $h / 4
@ u = $h % 4
@ v = (32 + 2 * $n + 2 * $s - $r + $u) % 7
@ w = ($j + 11 * $r + 22 * $v) / 451
@ xp = $r + $v - 7 * $w - 114
@ x = $xp / 31
@ d = $xp % 31 + 1
echo '		' $x $d
Newsgroups: comp.unix.shell
From: hellmann@cs.scarolina.edu (Doug Hellmann)
Subject: Re: How to calculate the Date of Easter?
Organization: USC  Department of Computer Science
Date: 14 Oct 92 13:39:45 GMT

michael@gandalf.moria (Michael Haardt) writes:

>In article <1992Oct9.175611.8231@maths.nott.ac.uk>, anw@maths.nott.ac.uk (Dr A. N. Walker) writes:
>> In article <1992Oct8.154757.21053@panix.com> fnord@panix.com
>> (Cliff Heller) writes:
>>>I believe Easter is defined as the first Sunday after the first full moon
>>>after the first day of spring.

This is the definition I have always heard.  Is there an easy way to figure
out what day is the first day of spring?  I have a formula which will give the
day of the week if you know the day of the year (1..365).  So if there is a
way to figure out what day is the first day of Spring, then you could brute
force the rest of the answer.

>I also wrote such a program a few years ago, and got the algorithm from
>an older math book.  It was said to be defined by Gauss.  There were (as
>far as I can remember) different magic constants for different
>centuries.  If there is interest, I can look if I find the book and
>either post title and publisher or post the algorithm.

I would be interested.

>Michael

Doug Hellmann
hellmann@cs.scarolina.edu

--
From: chet@odin.ins.cwru.edu (Chet Ramey)
Newsgroups: comp.unix.shell
Subject: Re: Alias in CSH and KSH
Date: 11 Oct 1992 03:10:55 GMT
Organization: Case Western Reserve University, Cleveland, OH (USA)
NNTP-Posting-Host: odin.ins.cwru.edu

In article <160.3468@incc.com> jerry@incc.com (Jerry Rocteur) writes:
> Why not?????

Because ksh aliases are not like csh aliases, which are ``most often
used to clumsily emulate shell procedures'' [4.3 BSD csh.1].  They are
simple textual substitutions.  ksh has shell functions to do the
hard stuff.

>  I tried it and you are quite right, ksh does not work when you
>  have an alias for this, when I do:
>
>  alias -x grap='grep -i $* /etc/passwd'
>
>  and I run it I get grep can't open ... where ... is the argument!  

Here's what happens:

Type
	grap xx

The shell expands the token `grap' into the sequence of tokens resulting
from the alias expansion, resulting in

	grep -i $* /etc/passwd xx

Since you're probably typing this at an interactive shell that was
started without arguments, $* expands to nothing, leaving

	grep -i /etc/passwd xx

which is probably not what you intended.

>  yet, I can have:
>
>  alias -x j='ls -l $*'
>
>  and it works like a charm, I just want to know WHY ?????

Now think about what happens when you type 

	j xx

in light of the previous example and it should be clear.

Chet
-- 
``The use of history as therapy means the corruption of history as history.''
	-- Arthur Schlesinger

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu
From: imtst@icarus.lis.pitt.edu (I-Ming Tsai)
Newsgroups: comp.unix.shell
Subject: Where to get the document of new features in Tcsh and Bash.
Date: 9 Oct 92 03:03:29 GMT
Organization: University of Pittsburgh


Where can I get a documentation talking about the new features 
in Tcsh or Bash. (besides man pages :-).

Thank you!

-- Ming
Newsgroups: comp.unix.shell
From: michael@gandalf.moria (Michael Haardt)
Subject: Re: How to calculate the Date of Easter?
Reply-To: u31b3hs@pool.informatik.rwth-aachen.de (Michael Haardt)
Organization: An old and gray machine, somewhere in Moria.
Date: Tue, 13 Oct 92 22:11:08 +0100
Return-Path: <u31b3hs@pool.informatik.rwth-aachen.de>

In article <1992Oct9.175611.8231@maths.nott.ac.uk>, anw@maths.nott.ac.uk (Dr A. N. Walker) writes:
> In article <1992Oct8.154757.21053@panix.com> fnord@panix.com
> (Cliff Heller) writes:
>>I believe Easter is defined as the first Sunday after the first full moon
>>after the first day of spring.

I also wrote such a program a few years ago, and got the algorithm from
an older math book.  It was said to be defined by Gauss.  There were (as
far as I can remember) different magic constants for different
centuries.  If there is interest, I can look if I find the book and
either post title and publisher or post the algorithm.

Michael
From: jrichter@sinix.UUCP (Juergen Richter)
Newsgroups: comp.unix.shell
Subject: Re: ksh, pipes, co-processes and stdout
Date: 7 Oct 92 13:56:51 GMT
Organization: SNI AG Muenchen, STO XS

Answer to Bennet Ih's question:
  { command >&3 |& } 3>&1 |  tee file
From: dt@yenta.alb.nm.us (David B. Thomas)
Newsgroups: comp.unix.shell
Subject: another "shell funny"
Date: 9 Oct 92 22:37:15 GMT
Organization: yenta unix pc, rio rancho, nm

Perhaps this isn't as funny as
$ ar t God
ar: God does not exist

but I just came up with this one:
$ mkdir describe_quayle
$ ls -l describe_quayle
total 0

					little david
-- 
I'm a poet and I'm unaware of it.
From: jrichter@sinix.UUCP (Juergen Richter)
Newsgroups: comp.unix.shell
Subject: Re: Read variable from stdin
Date: 7 Oct 92 13:57:39 GMT
Organization: SNI AG Muenchen, STO XS

Answer to Ashish Nedungadi's question:
  cp $1 <new_dir>
  chmod g+r <new_dir>/$1
Newsgroups: comp.unix.shell
From: root@trebor.uucp (Bob Stockler)
Subject: Re: Who's Calling Me?
Organization: Bob Stockler
Date: Fri, 09 Oct 1992 23:54:15 GMT

fmd3201@marst2 (Larry Baca VSW x9391) writes:

>Problem: Using csh.
>         I have one shell script which calls a second shell script and I
>	 don't want the second shell script to be executed by itself.

One way would be to call the second script, from within the parent script,
with something like:

  scriptname -YouReallyDon'tWantToRunMe

and have the second script exit it that argument weren't given to it.

It would be highly unlikely that your second script would be accidently
be run with an argument such as that (maybe?).
From: jch+@cs.cmu.edu (Jonathan Hardwick)
Newsgroups: comp.unix.shell
Subject: Re: Zsh users and prompting
Date: 7 Oct 92 13:27:40 GMT
Article-I.D.: cs.Bvr6q5.9u7.2
Organization: School of Computer Science, Carnegie Mellon

daniel@sdl.mdcbbs.com (Daniel Dignam) writes
> tom@dynamo.ecn.purdue.edu (Tom McCain) writes:
> : Has anyone tried to echo a blank line between their prompt?  There
> : does not seem to be a escape sequence to echo a newline for prompting.

That's because you don't *need* an escape sequence to include a newline.

> : Essentially what I want is a blank line to appear between prompts to
> : act as a "highlight".  Anyone tried this?  It's simple in bash but not
> : so simple in zsh....
> 
> I ended up with :-
> 
> PS1="`echo \"\n\"`%B%M !>%b "
> 
> Not so simple I agree :-), but I do prefer zsh.

Uuuuuugly :-)   Just use an imbedded newline in the prompt string.  For
example:

	~ $ PS1='			# start entering the string
	> %c4 $ '			# finish entering it
					# and now we have
	~ $ 				# a two-line prompt

Of course, if you've got CSH_JUNKIE_QUOTES set, you'll have to escape
the newline.  But IMHO csh junkies deserve all the masochistic pain
they get.... 

Jonathan H.
Newsgroups: comp.unix.shell
From: gec@panix.com (George Cabanas)
Subject: Re: How to use OFS in awk
Date: Mon, 12 Oct 1992 16:31:10 GMT
Organization: PANIX Public Access Unix, NYC

In <1992Oct12.005112.19412@adx.adelphi.edu> nancy@adx.adelphi.edu (Nancy Lee) writes:


>Hi there,
>	Could someone please tell me how to use the OFS in awk
>programming. I have tried something like 
>	BEGIN {FS=OFS=":"} or
>	BEGIN {FS=":";OFS=":"}
>But I still failed to change the output field separator to ":".
>The way right now I do it is to put it in the printing action like
>{print $1 ":" $2}. But according to lots of awk documentations the
>OFS can do it. Any info and pointers will be appreciated. Thanks in
>advance. BTW, I have tried this on SunOS/4.1.1 and Ultrix/4.2.

Nancy,
	I was able to get the following awk file to work to work
on SCO 3.2.2 :
BEGIN	{ FS=":" ; OFS=":" }

{	print $1, $2, $3 }

It may be something with your specific implementation of awk.


George
-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
George E. Cabanas		gec@panix.com
From: mdb@regal.cisco.com (Mark D. Baushke)
Newsgroups: comp.unix.shell
Subject: Re: Alias in CSH and KSH
Date: 12 Oct 92 14:45:26 GMT
Organization: cisco Systems Inc., Menlo Park, CA, USA

On Fri, 9 Oct 1992 08:07:17 GMT, nh@cbnewsg.cb.att.com
(nicholas.hounsome) said:

nh> From article <s913300.718528128@rubicon>, by s913300@rubicon (Nga Tran):
> 
> 	I would appreciate if someone can show me how to convert my alias
> 	from csh to ksh:
> 
> 		i.e: 	from csh:
> 
> 				alias grap 'grep -i \!* /etc/passwd'
> 
> 		  	to ksh
> 
> 				alias ....
> 
> 	Thanx advance.

nh> It cannot be done - ksh has no equivalent of \!*.
nh> Use a function instead.
nh> Alternatively bash or zsh can probably do it.

In bash, you would also need to use a function:

	function grap () { grep -i $* /etc/passwd }
or
	function grap () { grep -i $1 /etc/passwd }

I don't know zsh.

	-- Mark
	mdb@cisco.com
Newsgroups: comp.unix.shell
From: guenther@stolaf.edu (Philip Guenther)
Subject: Re: RSH leaving <defunct> processes
Organization: Academic Computing Center, St. Olaf College
Date: 16 Oct 92 18:12:01

In article <1992Oct16.141632.27719@bnr.ca> tor@bcars6c7.UUCP (Rene Tio) writes:
   Whenever I use rsh to run a background task on a remote machine, I get
   <defunct> processes around.  Methinks rsh does not understand to logout
   and clean up correctly if background tasks are being run, e.g.,

       % rsh -l <name> -n <host> "/usr/bin/X11/xterm -ls -display $DISPLAY &" &
       % ps -ax
       18777 p2 IW    0:00 rsh -l routing -n tor /usr/bin/X11/xterm -ls \
			   -display tor:0
       18779 p2 Z     0:00 <defunct>
       18780 ?  Z     0:00 <defunct>

   If I kill the parent 'rsh' process, the defunct processes go away as well.

   Anyway around this?

  There's a command that now comes in the X11 contrib stuff called xrsh.
It is specifically made to run background commands on remote machines
while leaving a minimum of zombies (usually 0).  Of course these
'background commands' are usually X commands ("xrsh lars.acc xload"
runs xload on lars.acc) and xrsh actually passes the DISPLAY
environment variable through the connection so it displays on your
current machine.  However, it should work just as well with plain old
background commands.
  Note that xrsh automatically backgrounds the remote job.  So leave
off that ampersand!

Philip Guenther
--
guenther@stolaf.edu (Philip Guenther)       | The ACC might agree with me,
Student Sys Prog, Academic Computing Center | but with that bunch, (and me)
St Olaf College, Northfield, MN 55057-1001  | you never know... :-) :-| :-(
"Life makes sense?  LIFE MAKES SENSE!!?  Where do people get these ideas?"-me
From: jrichter@sinix.UUCP (Juergen Richter)
Newsgroups: comp.unix.shell
Subject: Re: Rlogin with shell (ksh)
Date: 7 Oct 92 13:58:39 GMT
Organization: SNI AG Muenchen, STO XS

Answer to Tim Weil's question:
If you are user A on machine MA and want to login to machine MB as user B, put the line
  MA A
into .rhosts in B's home directory (.rhosts must be owned by B). After this you won't
be prompted for a password if you rlogin to MB by "rlogin MB -l B" from MA.