tell us what operating system and shell you're using,
show us the actual code that you are running,
show us the actual output produced when you run that code,
and clearly specify what it is that you are trying to do, what is not working, and indicate where you are stuck trying to fix your code.
Expecting the output to be
I asked what operating system and shell you're using. You have now shown us which OS you're using, but not which shell.
I asked what your shell script really was and what output was produced when you ran it. You have not done either of those. With the code you have shown us, running that code (assuming there is no utility in your PATH named RUN_FILE, that the variable RUN_FILE was not inherited in the environment, and that you ran that code using a shell that uses Bourne shell syntax) would produce output similar to:
If there is a utility named RUN_FILE in your PATH, a variable named RUN_FILE has been exported to your environment and initialized with a value similar to RUN_FILE, and you ran the script with a Bourne compatible shell, you'd get output similar to:
neither of which look anything like the output you say that code produces.
You say: "pipe forces a subshell to be created and once the loop completed.
the result of the variable which i got in inside the loop is reset after the loop.", but there is no pipeline in the code you showed us. The only pipe symbol in your script is inside a double-quoted string that is printed by the first echo in your script.
There is no way on earth to create a shell script where the command:
is going to print:
The expansion of $RUN_FILE could produce RUN_FILE if something in your script had set RUN_FILE=RUN_FILE, but there is no code anywhere in your script that does that. The expansion of $RUN_FILE could produce FALSE if something in your script had set RUN_FILE=FALSE, but there is no code anywhere in your script that does that. There is no way that two expansions of the same variable in a single echo statement will produce different results.
And, the command that was in your script:
is only sort of doing what you might have wanted it to do because the mismatched double-quote at the end of the line is matching another mismatched double-quote character somewhere else in your script. (In this case it is matching the double quote at the end of line #2 in your script.)
If you won't tell us what shell you're using (including its release number), show us the actual code you're running, show us the actual output that your code is producing, and CLEARLY explain what you are trying to do that is not working; we are wasting our time trying to help you.
This User Gave Thanks to Don Cragun For This Post:
Hi Gurus
I have a file called /tmp/CMDB which looks like this
serial: 0623AN1208
hostname: server1
model: x4100
assetID: 1234
I am writing a for loop that will go through this file line by line creating a variable of itself. Using the first iteration of the loop (i.e. the first line) as... (6 Replies)
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
hi all,
i am experiencing an error which i think an incorrect syntax for the where clause passing a variable was given. under is my code.
sqlplus -s ${USERNAME}/${PASSWORD}@${SID} << END1 >> $LOGFILE
whenever sqlerror exit
set serveroutput on size 1000000
declare
l_rc ... (0 Replies)
Hi all
Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Hi all
I run my program prog.c in the following way :
$ ./prog 1 > output.txt where 1 is a user defined initial value used by the program.
But now I want to run it for many a thousand initial values, 1-1000, and store all the outputs in different files.
Like
$ ./prog 1... (1 Reply)
Hi,
I want to read file multiple times. Right now i am using while loop but that is not working.
ex.
While read line
do
while read line2
do
echo stmt1
#processing some data based on data.,
done < file2.txt
done < file1.txt # This will have 10... (4 Replies)
Hi all,
I'm using a scipt with one input and one output.
I'm referring to the input by $1
after executing a command line, I'm getting the output via $1.
Normally, the $1 shouldn't get the same values between the first call and the second.
Is there a solution to force my second call for $1 to... (4 Replies)
Thanks all for taking time out and reading this thread and big Thanks to all who have come forward for rescue.
Background: I have a variable "nbrofcols" that has number of columns from a data file. Now, using this count in for loop, I am trying to get the maximum length of each column present... (7 Replies)
I have if loop with multiple variable value check in if loop. How can i print only if loop satisfied variable and its value in shell script ? I dont want to check each variable in if loop. That makes my script larger.
if ]
then
echo "Only satisfied variable with value"
... (3 Replies)