I have this piece of code inside a loop which runs n times.
I want to print or echo the value of "x" every time when it comes out of the loop (i.e if the loop condition is true). But unfortunately when
I echo the variable "x" 1st time it contains single value and when I echo variable "x" on the 2nd run of the loop I see values getting appended
to the 1st value i.e tab separated. If the loop runs for 5 times and if I echo the variable "x" at the last i get something like this
I'm pretty sure that statement will NOT assign any number to x let alone a series of numbers. Would you make it a correct command substitution x=$(...), then still it should assign one number only in each loop. And, as the command obviously does not change in the loop, the result should always be the same identical number.
Please post relevant parts of your script plus input (partial) files, so we can reproduce what you describe above.
I'm pretty sure that statement will NOT assign any number to x let alone a series of numbers. Would you make it a correct command substitution x=$(...), then still it should assign one number only in each loop. And, as the command obviously does not change in the loop, the result should always be the same identical number.
Please post relevant parts of your script plus input (partial) files, so we can reproduce what you describe above.
Following are the actual lines from the script:
Code:
#!/bin/ksh
fname=$1
for batchname in $(grep -i "Processing batch" $fname | cut -d "'" -f2)
do
Batch_state=`grep -c -i "Batch '$batchname' was successful" $fname`
if [[ "$Batch_state" -ge 1 ]];then
S_Time=`awk '/[0-9]_[0-9].*successful/{getline;getline;getline;print}' $fname | awk '{print $2}'`
E_Time=`awk '/[0-9]_[0-9].*successful/{getline;getline;getline;getline;print}' $fname| awk '{print $2}'`
echo $batchname"\t"$S_Time"\t"$E_Time
}
else
{
echo $batchname encountered an error
}
fi
done
I can't see any error - no reason to complain. Please convince me that sth is wrong!
Additional to the above info about the log, the given above log has 9 lines and these 9 lines are the unique lines, In real time my original log will have this 9 lines or this block repeated n times with batch numbers changed in each block or sequence .
Hence now coming to the point when this script is used for a log with more than one block or one sequence , the problem arises there I.e all the extracted are saved in a varible tab separated as shown above.
I have the following script, and I want to assign the output ($10 and $5) from awk to N and L:
grdinfo data.grd | awk '{print $10,$5}'| read N L
output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
I want to make a config file which contain all the paths.
i want to read the config file line by line and pass as an argument on my below function.
Replace all the path with reading config path line by line and pass in respective functions.
how can i achieve that?
Kindly guide.
... (6 Replies)
Hi all,
Warm regards!
I am in a difficult situation here. I have been trying to create a shell script which calls another shell script inside. Here is a simplified version of the same.
Calling Script.
#!/bin/ksh
# want to run as a different process... (6 Replies)
Hi Guy's.
Hopefully someone can help me with what I am trying to archieve.
So situation currently is, I have a script already setup however I have another script that sits infront of it.
The main script basically goes and searchs multiple platforms for a list of entered data.
In... (10 Replies)
Hi all,
Hereby wish to have your advise for below:
Main concept is
I intend to get current directory of my script file.
This script file will be copied to /etc/init.d.
A string in this copy will be replaced with current directory value.
Below is original script file:
... (6 Replies)
Hi Guys
I'm trying to search for all lines that that do not contain the dash (-) in it.
eg - I have the following list of numbers.I want to see those that donot contain the (-) in it.In this case '20151'
20151-60882
20151-60883
20151-60891
20151
20151-60893
Thanking you in advance. (3 Replies)
Hi there,
This may be a stupid question, but...
Is it possible to use one data connection channel initiated on a FTP server for sending multiple commands (LIST, NLST, MLSD)?
Thanks in advance! (1 Reply)
Dear All,
we have a command output which looks like :
Total 200 queues in 30000 Kbytes
and we're going to get "200" and "30000" for further process. currently, i'm using :
numA=echo $OUTPUT | awk '{print $2}'
numB=echo $OUTPUT | awk '{print $5}'
my question is : can I use just one... (4 Replies)
HI ,
Is there any way to return a value of variable from shell to perl script.
Code:
===
Perl file
my $diff1=system("sh diff.sh");
my $diff2=system("sh diff1.sh");
I need exit status of below commands
i.e 0 and 1 respectively.
Since in both the cases diff is working so system... (3 Replies)
Hi,
I have some ps files where I want to ectract/copy a certain number from and use that number to rename the ps file.
eg:
'file.ps' contains following text:
14 (09 01 932688 0)t
the text can be variable, the only fixed element is the '14 ('. The problem is that the fixed element can appear... (7 Replies)