It is currently Mon, 27 Jun 2022 12:48:50 GMT



 
Author Message
 Creating shell variable containing substring of another variable.
Please excuse this... I'm VERY inexperienced with Unix.

I am trying to create a shell variable within a script that removes the
letter E from within another shell variable.

I can create the result by using
     echo $var | sed 's/E//'

however I can't assign this to my other variable.

This is probably very easy... but I'm stumped.

Any help would be greatly appreciated.

Please direct responses to v.cast...@cowan.edu.au



 Wed, 22 Jul 1998 03:00:00 GMT   
 Creating shell variable containing substring of another variable.
In article <31130AF4.5...@cowan.edu.au>,
Vaughan Castine  <v.cast...@cowan.edu.au> wrote:

In the Bourne shell, a string in backquotes evaluates to the output of
the command inside the string. So:

a=`ls`

...will put a list of file in a. (Returns are treated as white space.)
So, you want:

list=`echo $var | sed 's/E//'`

(Note the confused quotes!)

If you're using csh for your scripts, switch to the Bourne shell. NOW.
csh is awful for scripts.

--
-------------------------------------------------------------------------------
   Why do people surf the Information Superhighway? Won't they get run over?
               http://www-hons-cs.cs.st-andrews.ac.uk/~dg
              Sun-Earther David Daton Given  of Lochcarron



 Thu, 23 Jul 1998 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. Passing shell variable to awk that contains spaces

2. Create variable named variable$i in for loop

3. file contents into variable, or global variable from shell script

4. Mixing Shell variables and AWK variables

5. prefixing a shell variable with a variable number of spaces

6. korn shell variable in variable access

7. ENV Shell Variable to Normal Variable Qn

8. difference between shell variable and environment variable

9. capturing an output variable into a shell variable

10. Linking Shell Variable with C Variable and vice versa


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software