[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scripts one after the other

From: Greg Wooledge
Subject: Re: scripts one after the other
Date: Mon, 28 Mar 2016 07:57:06 -0400
User-agent: Mutt/

On Sat, Mar 26, 2016 at 01:28:56AM +0000, Val Krem wrote:
> Both scrips do have common variables  (var1 , var2 and var3) and also some 
> input and output folder name defined.
> At the present I have defined the variables and folders path in both scripts.
> Instead of this,  is it possible to combine the two scripts in one so that I 
> can define the varietals at one spot.  It would be less prone to error.

Yes, you can obviously write a single script that does the work of
both of them.  Or you can move the variables to a config file, and
source that from both scripts.

> unzip ${df1}/'var.zip' -d ${f1}
> hashE ${f1}/${var1}_filename.csv>  ${f2}/output.txt

You really need to quote properly.

unzip "$df1/var.zip" -d "$f1"
hashE "$f1/${var1}_filename.csv" > "$f2/output.txt"

And so on.

All parameter expansions should be double-quoted, except in the small
number of places where it's unnecessary.  If you don't know what those
exceptions are, then *always* double-quote.  It never hurts.

The curly braces are optional in all cases except when the variable name
is followed by legal identifier characters, as in your ${var1}_filename
case here.  The curly braces are never a substitute for quotes.  The
quotes are still required.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]