I want to copy a value from a file as follows:
file contains line
now if I use grep command as follows
it will output
I want to store that value(10) in some local shell variable.
RudiC probably meant to leave out if. However this approach is a bit flawed in the sense that if xVal is not present in the file then VAL will probably still pick up a vaiue.
Try this modification:
This User Gave Thanks to Scrutinizer For This Post:
Your code working fine. But I want to learn how it is working exactly.
Can you explain something?
also I want to fine xVal based on its occurrence.
I mean if file containg
Your code reading 1st xVal.
I taught "xVal =" will read exact the value i want. But how can I specify it in while loop?
---------- Post updated at 08:21 PM ---------- Previous update was at 08:19 PM ----------
To be more specific I want to read a xVal where the line starts with xVal && followed by =, then i want to read value as shown below ---------- Post updated at 08:23 PM ---------- Previous update was at 08:21 PM ----------
Dear wisecracker,
I really didnt understand where you are reading file.
where is your file to the code?
Quote:
Originally Posted by wisecracker
Longhand using OSX 10.7.5, default bash terminal...
Results:-
It uses space as s separator between words. So when the read statement is executed on that particular line, label will contain xVal , dummy will contain = and val will contain 10 .
So if we use this line instead, then it should work..
You will probably want to use a different name than "dummy" since now it has a function..
Last edited by Scrutinizer; 08-24-2014 at 12:53 PM..
This User Gave Thanks to Scrutinizer For This Post:
I'm trying to copy script output and use it in this same script as a variable, and call the variable when script is compiled.
The script is below.
#!/bin/bash
output=$(script)
while read line; do
if ];
then
grep "$line" logfile.txt
# Create text file
echo "From: IT ... (4 Replies)
Hi experts
cp bin root src /mnt
but not copy bin/bigfile
any help?
( I post this thread in the "redhat" forum wrongly, I don't know how to withdraw that question in that wrong forum)
Thanks (6 Replies)
Hi,
We Perfrom Loads to the database through a Perl script which generates a statistics file. I need to read the statistics. the Statistics file looks something like below:
Process Beginning - 08-26-2010-23.41.47
DB2 CONNECTION SUCCESSFUL!
Ready to process and load file: FILENAME
# of... (2 Replies)
When script is running you only see when some of the commands are not successfull.
Is there a way to see which command are executed and to show the substitution of variables as every line is executed ? (3 Replies)
Hi,
I need to parse a simple text file like below and store the word that starts with BR* to a variable say $BRno. I need to do this in sh script.
NOTE: the length of the numbers following BR is not constant (eg: it could be BR1234 or BR22233). And there is only 1 BRxxxxx in a file at a given... (6 Replies)
Hi all,
I have a variable say var1 (output from somewhere, which I can't change)which store something like this:
echo $var1
name=fred
age=25
address="123 abc"
password=pass1234
how can I make the variable $name, $age, $address and $password contain the info?
I mean do this in a... (1 Reply)
Hi,
i was using a input file to get the last line of the file.But now i have stored
the values from the file to a variable and want the last line from the variable . Slightly confused on how to extract that data from the variable.
previous code,
cat input.txt
<TIME>00:15:48</TIME>... (2 Replies)
I have found a question from the exercises of my study mat. The question is
"Why are there a in-core copy and a disk-copy of i-node block and super block?"
If any one know the proper answer then please send me..... (1 Reply)
Hello ,
i am on linux,
and im trying to figure out why my cp command cant copy one file.
I am trying to use variable in which i stored path to location where is file i wish to copy.
$ echo $ORA_ALERT_LOG
/u01/app/oracle/diag/rdbms/ring11/ring11/trace
$
$
$ pwd
/home/oracle
$ cp -p... (2 Replies)