HDTenEightyP/NetNews huggingface dataset:
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Question on C shell syntax
Originator: tchrist@pixel.convex.com
Date: Tue, 6 Oct 1992 16:31:19 GMT
Distribution: ca
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: Convex Computer Corporation, Colorado Springs, CO
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

From the keyboard of darrell@netcom.com (Darrell Sell):
:Is this quoted approach good programming practice for C shell?

No approach is good programming practice for C shell.  Period.

--tom


-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
    "...this does not mean that some of us should not want, in a rather
    dispassionate sort of way, to put a bullet through csh's head."
                Larry Wall in <1992Aug6.221512.5963@netlabs.com>
Newsgroups: comp.unix.shell
From: dinguyen@wam.umd.edu (Dzi Nguyen)
Subject: #!/bin/sh | #!/bin/ksh ...
Organization: University of Maryland, College Park
Date: Wed, 30 Sep 1992 22:34:51 GMT

Hi Netter,

  I am new to the unix system, but I love it....Lately I start writing
lot of shell scripts and also learning  lot of new things.  I think that
I encountered which really bother, 'cause I couldn't find any documentation
about it that is most shell script at the top of the files they always have
this line:
#!/bin/sh 
or
#!/bin/ksh
or
#!/bin/csh
or even
:

what are these signified? 8-((

I hope this question is not a FAQ, if it is please show me the way to look at.

Thanx in advance....

Zombie (dinguyen@wam.umd.edu)

-- 
**********************************************************
*     There is no victim, only volunteers.               *
**********************************************************
Newsgroups: comp.unix.shell
From: dschleef@sage.cc.purdue.edu (Dave Schleef)
Subject: Re: sed question.
Organization: Purdue University Computing Center
Distribution: usa
Date: Tue, 29 Sep 1992 22:49:13 GMT

In article <1992Sep29.212427.5010@ncsa.uiuc.edu> vijay@ncsa.uiuc.edu (Vijay Rangarajan) writes:
>In article <1992Sep29.191410.3307@ncsa.uiuc.edu> vijay@ncsa.uiuc.edu (Vijay Rangarajan) writes:
>>How would I substitute space by newline in a file using sed ?
>
>A.Raman@massey.ac.nz emailed me suggesting tr ' ' '\012' to do the
>job, instead of using sed.
>
>>is it possible to do that with sed ?
>
>Probably not.
>
>Vijay.

try this: (using ls -l to make some spaces in the pipe)

ls -l | sed 's/ /\
/g'

press a return after the backslash, and it will be included into
the stuff given to sed.  The shell (I'm using ksh) gives back a second
command prompt, usually ">" for the second line.

dave.
From: vijay@ncsa.uiuc.edu (Vijay Rangarajan)
Newsgroups: comp.unix.shell
Subject: sed question.
Date: 29 Sep 92 19:14:10 GMT
Article-I.D.: ncsa.1992Sep29.191410.3307
Distribution: usa
Organization: Nat'l Ctr for Supercomp App (NCSA) @ University of Illinois
Originator: vijay@picard.ncsa.uiuc.edu

How would I substitute space by newline in a file using sed ?

I have a bunch of numbers separated by white space -

1.234 3.225 6.785 

and I would like to arrange them by rows -

1.234
3.225
6.785

is it possible to do that with sed ?

Thanks,

Vijay.
Newsgroups: comp.unix.shell
From: bruno@athena.mcrcim.mcgill.edu (Bruno Hall)
Subject: First character in a string -- SUMMARY
Organization: McGill University Broom Closet
Distribution: na
Date: Sat, 3 Oct 92 04:49:52 GMT

I wrote:

>I'm trying to extract the first character from a shell variable, and
>can't seem to sed myself out of this one.

And these kind folks wrote:

lhjensen@phoenix.Princeton.EDU: echo $SHELL | sed 's/\(.\).*/\1/'
dinguyen@wam.umd.edu:           echo $SHELL | cut -c-1
donp@hpbs1639.boi.hp.com:       echo $SHELL | cut -c1
plobo@us.oracle.com:            echo $SHELL | cut -c1
edwardsk@cuugnet.cuug.ab.ca:    expr $SHELL : '\(.\)'
bobb@netcom.com:                echo $SHELL | awk '{print substr($1,1,1)}'
aldavi01@starbase.spd.louisville.edu:
                                echo $SHELL | perl -ne '/^(.)/; print$1;'

Thanks for all the replies!

Bruno
-- 
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Bruno Hall  |  VE2HUM  |  bruno@mcrcim.mcgill.edu         
McGill Research Centre for Intelligent Machines - Controls Group
New systems generate new problems -- Join the Flat Earth Society.
From: brad@SSD.CSD.HARRIS.COM (Brad Appleton)
Newsgroups: comp.unix.shell
Subject: Re: First character in a string -- how?
Date: 2 Oct 1992 20:51:07 GMT
Organization: Harris Computers Systems Division, Fort Lauderdale,FL
Distribution: na
NNTP-Posting-Host: hcx1.ssd.csd.harris.com
Summary: Use any of expr, cut, sed, awk, or perl

In article <1992Oct2.171115.27063@thunder.mcrcim.mcgill.edu> bruno@athena.mcrcim.mcgill.edu (Bruno Hall) writes:
>A kiddie-question?  Probably :-).
>
>I'm trying to extract the first character from a shell variable, and 
>can't seem to sed myself out of this one.
>
>Any ideas?
>
using expr:
   $ expr "$var" : "\(.\).*"

using cut:
   $ echo $var | cut -c1-1

using sed:
   $ echo "$var" | sed 's/^\(.\).*/\1/'

using awk:
   $ echo "$var" | awk '{ print substr($1, 1, 1); }'

using perl:
   $ echo "$var" | perl -ne 'print substr($_, 0, 1);'
or
   $ echo "$var" |  perl -pe 's/^(.).*/$1/;'


Also - depending on which shell you are using, you may even be able
to get what you want using variable substitution/expansion.



______________________ "And miles to go before I sleep." ______________________
 Brad Appleton           brad@ssd.csd.harris.com       Harris Computer Systems
                            uunet!travis!brad          Fort Lauderdale, FL USA
~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
From: bih@mowgli.East.Sun.COM (Bennet Ih - Sun BOS Hardware - Sunergy)
Newsgroups: comp.unix.shell
Subject: ksh, pipes, co-processes and stdout
Date: 1 Oct 1992 21:44:08 GMT
Organization: Sun Microsystems Inc. - BDC
Distribution: world
Reply-To: bih@mowgli.East.Sun.COM
NNTP-Posting-Host: mowgli.east.sun.com

Hi... I have a ksh script that starts another program as a co-process using the
|& operator. Does anyone know of a way to prevent the co-process' stdout
from being redirected back into ksh? Right now I'm using:

PIPECMD="spinal_tap proc_sw main software /net/mowgli/files/scan_p2 $1"
TTO="/dev/tty"

eval "$PIPECMD >$TTO 2>$TTO |&" 2>$PIDOUT || STAP_RC=$?

Problem is that I want to run tee to keep a log of stdout. It seems that
redirecting stdout to /dev/tty causes problems with tee (I get an empty log).
Any suggestions are greatly appreciated. Thanks in advance.

-Bennet
From: hiebm@acf3.nyu.edu (Michael Hieb)
Newsgroups: comp.unix.shell
Subject: Help compiling tcsh-6.02 on SYSVr3.2
Summary: Need help compiling tcsh-6.02 on SYSVr3.2
Keywords: help SYSVr3.2 tcsh compile
Date: 27 Sep 92 01:51:51 GMT
Organization: New York University

Can anyone lend asistance/ I am trying to compile tcsh on an Everex STEP
386/25 running ESIX SYSVr3.2 rev D (identical to ATT SYSVr3.2 except for
additional device drivers for Everex equipment). 

I receive the follwoing errors. I guess they would be pretty simple if I
were more of a programming type.


malpais% make
        /bin/cc   -O -I. -I.. -I/usr/include  ed.screen.c
"ed.screen.c", line 1276: unknown size
"ed.screen.c", line 1279: ws_col undefined
"ed.screen.c", line 1279: member of structure or union required
"ed.screen.c", line 1280: member of structure or union required
"ed.screen.c", line 1281: ws_row undefined
"ed.screen.c", line 1281: member of structure or union required
"ed.screen.c", line 1282: member of structure or union required
*** Error code 1

Stop.

You can respond to me diredctly as I doubt the rst of the world is
really interested in this problem.

Many thanks for your response.

Michael
Newsgroups: comp.unix.shell
From: dattier@ddsw1.mcs.com (DWT)
Subject: Re: First character in a string -- how?
Date: Sun, 4 Oct 1992 05:18:59 GMT
Distribution: na
Organization: Contributor Account at ddsw1, Chicago, Illinois  60657

bruno@athena.mcrcim.mcgill.edu (Bruno Hall) wrote in
<1992Oct2.171115.27063@thunder.mcrcim.mcgill.edu>:

| I'm trying to extract the first character from a shell variable, and 
| can't seem to sed myself out of this one.

If you must use sed,
initial=`echo $variable | sed 's/\(.\).*/\1/'`

but expr is likely to be smaller, so
initial=`expr $variable : '\(.\).*'`

In ksh you can do this with no extra processes:
typeset -L1 initial
initial=$variable

David W. Tamkin   Box 59297   Northtown Station, Illinois  60659-0297
dattier@ddsw1.mcs.com    CompuServe: 73720,1570    MCI Mail: 426-1818
From: tcamp@acpub.duke.edu (Ted A. Campbell)
Newsgroups: comp.unix.shell
Subject: BASIC as shell/What makes a shell?
Date: 4 Oct 92 16:53:44 GMT


I have been debugging a simple, line-oriented BASIC interpreter
which I hope to release soon as source code (probably comp.sources.misc
stuff).  The interpreter implements (under ANSI C) all of the (few)
commands andfunctions of ANSI Minimal C, and has a user interface
roughly similar to older Microsoft-type BASIC interpreters, where
the user can enter a line preceded by a line number and it is
added to the program in memory; the program in memory can be saved
as an ASCII file, etc.  

I have added one feature to this interpreter which might qualify it
as a shell language: whenever a line is entered that a) does not
begin with a recognized BASIC command and b) is not an implied
LET command, the interpreter shells out (using shell()) and tries
to let the default o.s. command shell interpret the line. So
that under Unix the line "ls -l" will simply be executed by sh
or whatever the default shell is, and any executable file can
be executed by entering it at the (BASIC) prompt. 

My questions, then: (a) why couldn't BASIC serve as a command
shell in place of sh, ksh, csh etc.? and implied in this question,
(b) wat do think is necessary for a shell programming language
beyond the bare ability to execute commands that another shell
can execute? Perhaps implicit, further, is (c) the question of
whether there is a better term than "shell" for this, since
after all it does not execute commands directly but calls up the
default shell to do so? Perhaps I should execute them using 
execl() or some such? Perhaps I should call my implementation a
"subshell? Or is there another term in use for this kind of
program? 

Thanks very much. 

Ted A. Campbell
Duke University
tcamp@acpub.duke.edu
From: eric@dekalb.dc.peachnet.edu (Eric Weylin Scoggins)
Newsgroups: comp.unix.shell
Subject: question
Date: 1 Oct 92 14:20:07 GMT
Organization: C4 Computing, Atlanta, GA

I have a program that runs in the background. When I log off, because of the
way the program is set up, it keeps running. My question is this, how can I 
set up a script that will restart it from time to time, even when I am not
logged on. This program uses memory at an increasing rate over time, so it
becomes necessary to restart it.
thanks
-eric
-- 
====================================================================
'There are two things that were created at Berkeley:
            UNIX and LSD'
====================================================================
From: root@candle.uucp (Bruce Momjian)
Newsgroups: comp.unix.shell
Subject: Add ksh arrow keys mappings to FAQ?
Date: 27 Sep 92 20:09:59 GMT
Organization: a consultant's basement
X-Newsreader: Tin 1.1 PL5

Here is a question I think should be in the FAQ.  It is not well
documented in the manuals I have seen.

-----------------------------------------------------------------------
How do I define my arrow keys so I can retrieve and edit command history in
the korn shell?

	First, make sure you are in emacs mode.  Try:

		set -o emacs

	Next, put these aliases in your $HOME/.kshrc file:

		alias __A=^P		# up arrow
		alias __B=^N		# down arrow
		alias __C=^F		# right arrow
		alias __D=^B		# left arrow
		alias __H=^A		# beginning of line, HOME key
 		alias __Y=^E		# end of line, END key

	Note that the '^P' above is a real Control-P, not a ^ and a P. 
	The last two bindings may be different for your keyboard.  BTW,
	any alias beginning with __ translates to ESC-[.
-- 
Bruce Momjian                          |  830 Blythe Avenue
root%candle.uucp@bts.com               |  Drexel Hill, Pennsylvania 19026 
< If your life is a hard drive,      > |  (215) 353-9879(w)  853-3000(h)
< Christ can be your backup.         > |
Newsgroups: comp.unix.shell
From: trw@unixland.natick.ma.us (Tim Weil)
Subject: Rlogin with shell (ksh)
Organization: Unixland Public Access Unix  (508) 655-3848
X-Newsreader: Tin 1.1 PL3
Date: Sun, 4 Oct 1992 00:48:09 GMT

Can rlogin be  performed in Korn Shelll script language
 including response to the password prompt?  So far, we
 are limited to using the .rhosts file which allows users
 without passwords to login.
 
 Thanks in advance

 Timothy.Weil@dialcom.tymnet.com
Organization: Stanford Linear Accelerator Center
Date: Tuesday, 29 Sep 1992 11:37:25 PST
From: <CATHIE@SLACVM.SLAC.STANFORD.EDU>
Newsgroups: comp.unix.shell
Subject: Free Versions of REXX for Unix

In response to inquiries and with credit to Eric Giguere (because I lifted
this from his REXX FAQ list, available on comp.lang.rexx):

    Currently there are three freely-distributable interpreters (with
source) for Unix machines, all available for anonymous FTP from
rexx.uwaterloo.ca:

    /pub/freerexx/regina/regina-0.03d.tar.Z       254939   ANSI C
          files originally from flipper.pvv.unit.no

    /pub/freerexx/alrexx/rx102.tar.Z              671904   C++ (using GNU G++)
          files originally from tony.cat.syr.edu

    /pub/freerexx/imc/rexx-imc-1.3.tar.Z          491691   ANSI C
          currently only runs on SunOS machines

To compile, the first two interpreters require Lex and Yacc (or suitable
clones).  All are still beta versions, though imc has been around the longest
and claims to be quite stable.  (Note: "regina" was called "andersrexx"
in previous FAQs because I couldn't remember the interpreter name.)
-------------------------------------------------------------------------
Questions/comments/suggestions about this FAQ should be sent to Eric Giguere,
giguere@csg.uwaterloo.ca.

Cathie Burke Dager   cathie@slacvm.slac.stanford.edu
---> the opinions expressed are mine alone and not necessarily those
     of SLAC, Stanford University or the DOE
---> REXX Symposium    May, 1993    San Diego, California
Newsgroups: comp.unix.shell
From: stavast@rls.b11.ingr.com (Lyle Stavast)
Subject: Re: sed question.
Reply-To: stavast@rls.b11.ingr.com
Organization: Intergraph Corp. Huntsville, AL
Distribution: usa
Date: Wed, 30 Sep 1992 18:00:17 GMT

In article <1992Sep29.191410.3307@ncsa.uiuc.edu>, vijay@ncsa.uiuc.edu (Vijay Rangarajan) writes:
|> How would I substitute space by newline in a file using sed ?
|> 
|> I have a bunch of numbers separated by white space -
|> 
|> 1.234 3.225 6.785 
|> 
|> and I would like to arrange them by rows -
|> 
|> 1.234
|> 3.225
|> 6.785
|> 
|> is it possible to do that with sed ?

Try using this sed command, which I believe is essentially what you want,
except that I just did it for one space character, you'll have to get
the tabs and multiple spacing things incorporated into the first part
of the sub command:

echo "foo foobar fooodo zoobie" | sed -e 's/ /\^J/g'

(the ^J is a single escaped control-j (newline) character)

It gives me newline terminated lines like this:

foo
foobar
fooodo
zoobie


|> 
|> Thanks,
|> 
|> Vijay.

-- 
+=======================================================================+
|      R. Lyle Stavast  stavast@rls.b11.ingr.com (205) 730-5624         |
+=======================================================================+
Newsgroups: comp.unix.shell
From: kherron@ms.uky.edu (Kenneth Herron)
Subject: Re: Accepting stdin as an input in Bourne shell script
Keywords: stdin,shell,Bourne,input
    <1992Sep27.083526.11626@news.yale.edu>
Organization: University Of Kentucky, Dept. of Math Sciences
Date: Sun, 27 Sep 1992 13:17:16 GMT
Distribution: na

>   #!/bin/sh
>   IN=/tmp/stdin.$$
>   cat >$IN

>   #treat $IN as if $IN pointed to a usual file name 
>   .........
>   lpr $IN
>   grep something $IN
>   .......
>   rm -f $IN

This type of construct isn't usually necessary, and raises the risk
of leaving /tmp/stdin.* files lying around.

Any program started through a shell script inherits the same stdin,
stdout, and stderr that the shell script itself has, assuming no
redirection/piping is involved.  Most filter-type programs (lpr falls
in this class) will automatically read from stdin if there are no
filenames mentioned on its command line.  Thus, to call lpr within
a script and have it read stdin, simply run lpr with no filenames,
ie

	lpr

The only danger from this approach is the possibility that some previous
process started by the script has drained some or all of stdin.  However,
this is usually a non-problem because random programs don't go around
doing this unexpectedly.
-- 
Kenneth Herron                                           kherron@ms.uky.edu
University of Kentucky                                      +1 606 257 2975
Department of Mathematics           "Thanks to the magic of the slow-motion 
camera, we can now show you how ugly the inside of someone's mouth can be."
Newsgroups: comp.unix.shell
Subject: Re: First character in a string -- how?
From: dave@cs.arizona.edu (Dave Schaumann)
Date: 3 Oct 92 04:24:54 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Distribution: na
Organization: University of Arizona

In article <1992Oct2.171115.27063@thunder.mcrcim.mcgill.edu>, bruno@athena (Bruno Hall) writes:
>I'm trying to extract the first character from a shell variable, and 
>can't seem to sed myself out of this one.
>
>Any ideas?

How 'bout this:

	echo $VAR | cut -c1

Works for me.

-- 
Dave Schaumann			dave@cs.arizona.edu
From: friedman@gnu.ai.mit.edu (Noah Friedman)
Newsgroups: comp.unix.shell
Subject: Re: First character in a string -- how?
Summary: using bash or ksh builtins
Date: 3 Oct 92 06:09:10 GMT
	<1aicnrINN8tg@travis.csd.harris.com>
Organization: Free Software Foundation, 675 Mass Ave. Cambridge, MA 02139
In-reply-to: brad@SSD.CSD.HARRIS.COM's message of 2 Oct 92 20:51:07 GMT

In article <1aicnrINN8tg@travis.csd.harris.com> brad@SSD.CSD.HARRIS.COM (Brad Appleton) writes:
>Summary: Use any of expr, cut, sed, awk, or perl
>
>In article <1992Oct2.171115.27063@thunder.mcrcim.mcgill.edu> bruno@athena.mcrcim.mcgill.edu (Bruno Hall) writes:
>>A kiddie-question?  Probably :-).
>>
>>I'm trying to extract the first character from a shell variable, and 
>>can't seem to sed myself out of this one.
>>
>>Any ideas?
>[many examples deleted]

   In bash (and probably in ksh as well), assuming variable "string"
contains the string from which you wish to get the first character (if
you have a string literal, you'll need to assign it first):

        rest="${string#?}"
        first_char="${string%${rest}}"

This works without calling any external programs.   It may work in some
versions of /bin/sh.  It probably won't work with most. 
Newsgroups: comp.unix.shell
From: tom@dynamo.ecn.purdue.edu (Tom McCain)
Subject: Zsh users and prompting
Organization: Purdue University, West Lafayette, IN
Date:  7 Oct 92 02:44:22 GMT


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.
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....
--

Tom McCain 
tom@ecn.purdue.edu
From: barr@pop.psu.edu (David Barr)
Newsgroups: comp.unix.shell
Subject: Re: Problem with background kill.
Date: 7 Oct 92 00:39:15 GMT
Distribution: usa
Organization: Penn State Population Research Institute

In article <1992Oct06.222430.29921@sernews.raleigh.ibm.com> shujaat@ferrari.raleigh.ibm.com () writes:
>Hi there,
>	I am experiencing a strange problem after executing my script
>, the problem is that once the shell gets executed the window in which
>the shell was executed does not display the commands on the command line
>but executes them.  On pressing return on the prompt the prompt shows back
>on the same line, rather than a new line.  Each time after executing the
>script I have to get a new window, inorder to test the script.  Another
>problem that I wanted to ask you guys was, how can I suppress the output
>after the kill commands output.      
>
>
>catchandkill() {
>	sleep 10
>	username=`who am i | cut -d' ' -f1`
>	processdetail=`ps -u$username | grep dosdir | cut -d' ' -f3`
>	if [ -n "$processdetail" ]; then
>		echo 'This is not a dos formatted disk.'
>		kill -9 $processdetail 
>	fi
>}

Well, this isn't a fix for the output of kill, but this is much nicer
solution that doesn't involve any external calls:

#!/bin/sh
dosdir $* &
WAITFOR=$!
(sleep 10; kill -9 ${WAITFOR} >/dev/null 2>&1)&
wait ${WAITFOR}

Whatever you do, avoid calling expensive programs like 'ps' and 'grep'.

--Dave
-- 
System Administrator, Population Research Institute    barr@pop.psu.edu
  loose: v. to set free, or adj. not securely fastened.
  lose: v. to miss from one's possession.
Newsgroups: comp.unix.shell
From: holger@is.morgan.com (Holger Veith)
Subject: how to skip last line in awk?
Organization: Morgan Stanley - IS
Date: Tue, 29 Sep 1992 21:53:22 GMT

Hi,

to simplify: lets say I have a column of number in ascii format.  I would like
to subtract one from every number except on the last line.

The actual problem is more difficult but basically I need to test if I am
on the last line and NOT do something.

     * is there a variable called LINES_IN_FILE which I could compare NR 
	(which is the current line) to?

     * this may be related to the FILENAME variable.

     * I guess I could set a variable to the wc (wordcount) of the file
       in the BEGIN{} section, but that is not too efficient.

     * instead of printing a line I could set it to a variable and once
       I read in the next line I could then print the variable (which would
       be the previous line).  The END{} segment would then print the last
       line.  This is sort of a pain-shift-the-login-in-the-file solution.


Does anybody have a good idea, or can tell me what is the best alternative?
I just recently started awk-ing ...

Thank you,

Holger.
Newsgroups: comp.unix.shell,comp.unix.questions
From: root@trebor.uucp (Bob Stockler)
Subject: Re: Help with sysv bourne expr command
Organization: Bob Stockler
Date: Thu, 01 Oct 1992 22:03:53 GMT

nrs2495 (Bill Reed ) writes:

>What I am trying to do here is get a total count in megabytes, that these 
>certain filesystems take up.  Everything works fine, except for the "expr"
>line.  I just can't get it to add the cut material.  Does anyone see what
>I am doing wrong?  Or with bourne shell, is there another way of doing this?

"expr" does only integer math.

Here's one way of doing what I think you want:

dfspace2 |
awk ' { used += $3 ; avail += $6 }
  END { print "Total Used:", used, "MB of", avail, "MB Total Available" } '

(That is, if I correctly understand what your "dfspace2" command does.)

Newsgroups: comp.unix.shell