I have a simple script that runs an application,
This application can run for days at a time before it is finished and creates several thousand output files.
One problem I am having is that there are times when I look at some of the early output and decide that I need to change some of that parameters above, such as that values for EPOCHS. As it is, the value is read in and then the script runs about 2000 iterations using that value. There is no way to change the value without stopping the script, changing the value, and starting again.
It would be nice if I could have the script read in the values from a file before beginning a split.
If the values were read in before each split, then at least I could change the values in the control file and the revised values would get used for the next split. This is much better than constantly having to start over and clean up the partial output, etc.
I guess I could hack this up with sed or awk, but I have never opened and read the contents of a file from bash. The only similar things I have done are with file names, and I think it would be overly goofy to read in the values from a file name. (overly goofy even for me)
I thought I would ask if there was a standard way to do such a thing.
Put the commands you want to set the values of these variables in a file, such as set_values:
and then when you want your script to reset the values of those variables, issue the command:
These 2 Users Gave Thanks to Don Cragun For This Post:
There are a couple of reasons I have for wanting to read parameters from a file. One is that there are a number of them and the list is getting longer. It would be tedious to always have to enter in the values I want. I also need to keep track of these things to some extent and the combination of a script and something like an ini file gives documentation of what I did.
Overall, there seem to be some good reasons to have the values read in from a file and I am wondering how it could be done in bash.
Once again it is demonstrated that reading is a virtue. When I first read that post, I somehow understood that the commands like ARCH=arch_val went in the original script and you would somehow be prompted for the new values when you entered . set_values. So much for reading. I got sidetracked with some other problems and didn't get to test the posted code.
I will play around with this and see if I can get the hang of how it works.
Dear All,
I have been trying to do a simple task of extracting 2 fields from the file (3 rows) and store it in an array variable. I tried with:
#! /bin/bash
ch=`cut -f10 tmp.txt`
counter=0
for p in $pid
do
c=${ch}
echo "$c ..$counter"
counter=$((counter+1))... (2 Replies)
Hi,
I have a text file with multiple lines, each having data in the below format <DOB>,<ADDRESS>
I have to write a script which reads each line in the text file in loop, assign the values to these variables and do some further processing in it.
Using the following code prints the values... (12 Replies)
Hi,
I have a text file with multiple lines, each having data in the below format
<DOB>,<ADDRESS>
I have to write a script which reads each line in the text file in loop, assign the values to these variables and do some further processing in it.
Using the following code prints the... (1 Reply)
SHELL SCRIPT
Hi,
I have a file in which contents are as follows:
9999,abdc,123
9988,aba_12,2323
and so on
I want to read the contents of this file such that i can do
echo "This is $a followed by $b an then $c"
I tried the following but id did not work
cat test | cut -d ',' -f1|... (7 Replies)
I have a csv file with the values seperated by commas.I want to extract these values one by one and assign to a variable using shell script.Any ideas or code? (11 Replies)
i have a file in this format
curyymm PRVYYMM CDDMmmYY bddMmmyy eddMmmyy
--------- ------- ------------ ---------- -----------
0906 0905 09Jun09 01Jun09 30Jun09
----------- --------- ------------ ------------ -----------
i need to read the... (5 Replies)
Hello,
I have a cat.dat file, i would like shell to read each 3 lines and set this 3 lines to 3 different variables.
my cat.dat is:
11
12
+380486461001
12
13
+380486461002
13
14
+380486461003
i want shell to make a loop and assign 1st line to student_id, 2nd line to... (4 Replies)
Hi,
I have a 1-line file which looks like " First second third 4 five". I need to extract the number (here 4) in that line and put it in a variable. I will use the variable later to make few tests in my C shell script.
Can somebody help me? (2 Replies)
I am attempting to itterate through a file that has multiple lines and for each one read the entire line and use the value then to search in other files. The problem is that instead of an entire line I am getting each word in the file set as the value I am searching for. For example in File 1... (2 Replies)
Hi,
I want to pratmeterze my scripts like,
my confRsync file contains varibale values for 1. host 2. Destination and 3. source like this, I want to read this values from this and assing to my makeRsyn.sh file's varibales.
how to do this? (1 Reply)