pure bash, grep, sed??? best solution?

Björn Lindberg d95-bli at nada.kth.se
Tue Sep 10 02:30:44 PDT 2002

DJ Lucas wrote:
> Björn Lindberg wrote:
> > The whole thing seems extremely cumbersome. Why don't you tell us why
> > you want to do this, and maybe we can find an easier solution. For
> > instance, to directly get the runlevels into 2 variables, you can do
> >
> > runlevel | read PRL CRL
> >
> >
> > Björn
> Unfortunately...this has not worked for me.
> Could be user error :-$  hmmm  What are the variables for the return values
> for Runlevel?  And nevermind! lol  /me is learning to READ READ READ.  I
> could have saved quite a bit of time.  My apologies.

I'm sorry, I made a mistake. I'm using the Korn shell, where the last
command in a pipe is executed in the current shell; in bash, every
command in a pipeline is executed in it's own subshell, and the read
variables will be local to this subshell. There are two main solutions
to this, of which the first one is probably best in this case:

	PRL=${runlevels% *}
	CRL=${runlevels#* }


	runlevel | {
		read PRL CRL
		echo $PRL $CRL

Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-chat' in the subject header of the message

More information about the lfs-chat mailing list