07-24-2014
Is this a homework assignment?
You haven't specified nearly enough to know what should be done here. And, some requirements could make this an extremely complex job requiring a full syntactic and semantic understanding of the shell you're using and of all of the commands invoked by your script.
- What delimits the start and end of the variable assignments to be removed and expanded by your script?
- Are occurrences of expansions of these variables to be replaced inside pairs of single quotes?
- Does your script need to be smart enough not to replace $ECHO in the command: $LS $ECHO_OLD?
- Does your script need to be smart enough to replace ${ECHO} as well as $ECHO?
- Is your script to search out and replace these variables in dotted and sourced files?
- What if a script creates an intermediate encoding that result in one of these variables being expanded as a side effect of running eval?
- What if a printf invocation leads to a string being put into a variable that will be expanded and run later in the script?
What have you tried? With what you have tried, what isn't working?
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hey All,
I'm trying to clean up a variable using sed but It dosn't seem to work. I'm trying to find all the spaces and replace them with "\ " (a slash and a space). For Example "Hello World" should become "Hello\ World". But it does nothing. If I put it directly into the command line it works... (3 Replies)
Discussion started by: spragueg
3 Replies
2. UNIX for Dummies Questions & Answers
Hi everyone,
I have a simple question to ask :
In a script that I'm writting, I need to create variables on-the-fly.
For instance, for every iterartion of the following loop a var_X variable should be generated :
#!/bin/ksh
a="1 2 3"
for i in $a
do
var_${i}=$i
echo "${var_$i}"
done
... (1 Reply)
Discussion started by: ck-18
1 Replies
3. Shell Programming and Scripting
Hello Guys,
I have some variables declared as below
VARIABLE1=Table
VARIABLE2=VARIABLE1
Now when I do an echo $VARIABLE2 it gives me below
atrcus303{root} #: echo $VARIABLE2
VARIABLE1
I want to echo the value of VARIABLE1 using the VARIABLE2. So I tried to the below
atrcus303{root} #:... (1 Reply)
Discussion started by: Mohammed
1 Replies
4. Shell Programming and Scripting
Hello,
i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem.
my var1 is a string constructed like this:
filename1 filerev1 filepath1
my var2 is another string constructed like this:
filename2 filerev2 filepath2
when i do... (2 Replies)
Discussion started by: alrinno
2 Replies
5. Shell Programming and Scripting
file1.ksh
#!/bin/ksh
test5_create="I am a man" # test5 will be dynamic and the value will be passed from command line
a=${1}_create
echo $a # i need the output as "I am a man"
./file1.ksh test5 # i run the script like this
any suggessions guys... (1 Reply)
Discussion started by: giri_luck
1 Replies
6. Programming
Greetings!
Basically, I would like to properly handle this with gnu make:
alltools: my_tool mysecond_tool mythird_tool etc_tool
%_tool: dir1/%_tool.vf dir2/%_tool/subdir2/%_tool.ver
<tab>@echo done
%.vf:
<tab>RUN_VF $*
%.ver:
<tab>RUN_VER $*
So, if I were to do something like:... (0 Replies)
Discussion started by: Harlinator
0 Replies
7. Shell Programming and Scripting
Hi,
I want to get content of a$i variables with one command:
a1=/tmp1.log
a2=/tmp2.log
for i in 1 2;do
log=<some code>
echo $log
done
and get the content of a1 and a2:
/tmp1.log
/tmp2.log
Thanks (2 Replies)
Discussion started by: gdan2000
2 Replies
8. Shell Programming and Scripting
For example I have variable like below
echo $OUTPUT
/some/path/`uname -n`
when I try to use the variable OUTPUT like below
cd $OUTPUT or cd ${OUTPUT}
I am getting bad substituion error message
$ cd $OUTPUT
ksh: cd: bad substitution
$ cd ${OUTPUT}
ksh: cd: bad substitution
... (1 Reply)
Discussion started by: rajukv
1 Replies
9. Shell Programming and Scripting
Hi,
I have to write a shell script in which I have to substitute a variable within a variable. For example,
var1=aaa
var2=file.$var1.txt
The output should be,
echo $var2
file.aaa.txt
Can someone please help me in getting this. I tried using eval, but it didnt work. I might be using it... (2 Replies)
Discussion started by: grajp002
2 Replies
10. Shell Programming and Scripting
MyFile contains:
ALTER TABLE $DBN.$TBN
ADD $COL $TYP COMPRESS ($VAL);
I need to cat the file and have it substitute all of the variables with their contents. cat MyFile does not work. The following works for the first line, but errors on the second line because of the paren:
$ while read... (2 Replies)
Discussion started by: Phil27577
2 Replies