You will have to change the script file. BTW this is a less than useful way to run scripts because it negatively impacts performance. And prevents the use of variables defined in the input text file.
every "command " you read in you have to preface with
Please consider reading about it before you cause more problems for yourself.
example:
Note that when you do that you cannot have a variable set up in line 1 of input_file.txt
and then read the next line and use that variable. This is because each eval "line of text" runs in a separate child process. No variables are preserved in the current process. Each line is a separate world of its own.
That is a useless use of cat and will prevent variables set inside the loop from being used outside the loop.
There is also no point using awk to split variables here when read can do that by itself.
There's also no point using awk 10,000 times to process 10,000 lines when awk can do that all at once. It's like making a hundred phonecalls to say a hundred individual words.
This should do the job with less fuss:
p.s.: The -r is probably necessary either way to read shell code. Without it, code containing backslash characters may be mangled.
Last edited by Corona688; 01-18-2013 at 02:03 PM..
I need some help. I would like to read in a text file.
Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01.
Is this possible? any help is appreciated. (2 Replies)
Hello All,
I have a Bash Script and an Expect script that together will SSH to another server and
do some stuff there... From within the Bash Script I process the Command Line Arguments,
which are Required Args and Optional Args.
When I call the Expect script from the Bash Script, I pass... (4 Replies)
So, the beginning of my script will cat & grep a file with the output directed to a new file. The data I have in this file needs to be parsed, read and evaluated.
Basically, I need to identify the latest date/time stamp and then calculate whether or not it is within 15 minutes of the current... (1 Reply)
Can we input two variable on single line that separate by space example user input "list jpg" it will list all jpg files in current directory (3 Replies)
consider the small piece of code
while read line
do
echo $line
done < example
content of example file
sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr
the output is like
sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr
the... (4 Replies)
Hi,
I should read one character at a fixed position from each line of the file. So how ??? should be substituted in the code below:
while read line ; do
single_char=`???`
echo "$single_char"
done < $input_file (8 Replies)
Hi,
I am doing :
while read line
do
printf "%s\n" ${line}
done <datafile.txt
but I am not getting each single line from the data file assigned to the variable line (but only tokens/fields at a time). I also tried while IFS= read -r lineI want the whole line assigned or read into the... (2 Replies)
hi...
i need to open a file and read it line by line, and capture that it in to some variable and manipulate...
i need to get a line in to a variable
please help :confused: (1 Reply)
I'm a Linux newb, I've been running a Debian Linux server for about a year now, and I've written some simple scripts to automate various things, but I still don't know much, and I forget what I learn as fast as I figure it out... Anyway, that really isn't important, I just want you to know that... (14 Replies)
hello,
i need an algorithm which reads a line specified to it in shortest possible time.
i am already using sed, i need a better way. please suggest me alternatives (2 Replies)