output - KSH Resolving Environmental Variables for an Entire File -


I have a list of file names in which the environment variable in them I want to set a variable to read the file line by line and then read in a line, but the environment environment variable is translated into the appropriate environment variable. Even my script is:

  #! / Bin / ksh /test/currentEnv.sh While echoing line line for reading line & lt; $ 1   

If my source file is:

  foo1 $ ENVVAR1.csv foo2 $ ENVVAR2.csv foo3 $ ENVVAR3.csv   

and my environment variables in currentEnv.sh

  $ ENVVAR1 = Hello; ENVVAR1 $ ENVVAR2 = Export the world; ENVVAR2 $ ENVVAR3 = Export test; ENVVAR3 Export   

I want the results of the script

  foo1hello.csv foo2world.csv foo3test.csv   

current In this, it only removes the original file:

  foo1 $ ENVVAR1.csv foo2 $ ENVVAR2.csv foo3 $ ENVVAR3.csv   

edit

I was able to get the majority to solve using my files: #! / Bin / ksh

  /test/currentEnv.sh While reading line eval echo $ line   

Although some of my variables are in the middle of the string:

  foo3 $ ENVVAR3_bar.csv   

this An env variable starts searching for $ ENVVAR3_bar and I do not need it, I want it for output:

  foo3test_bar.csv    

  $ var = value # no var = value #  
  1. Yes

  2. Since underscore is a valid character for a variable name, ksh is trying to extend the named variable ENVVAR3_bar : Aus You need to use braces to separate the variable names from the text:

      foo3 $ ENVVAR3_bar.csv # no foo3 $ {ENVVAR3} _bar.csv # yes      

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -