"$I" is just the filenames so this is actually being piped to bc:
which is why reading down the right side of the errors gives you the filenames, minus the A, which it can apparently calculate. Learn something new every day.
Try this. It may not be the best approach but see if it works then we can go from there:
@ scottn:
The code I reported is a small piece of a 400 lines bash script, dealing with geographic coordinates manipulation.
In the version not looped, I've something like
and everything works fine. I would like to use a loop to use less lines of code.
@fubaya:
You're right: ${I} is substituted with my variable name and not with the variable content (which is for example "71 4 17.92" as reported in the comment above).
I cannot use "cat" as you suggested because ${I} are variables and not files.
There is a way to fix this?
I solved using "variable indirect references", explained here:
This is the shortest piece of code I can obtain: 4 lines instead of 16.
Thanks for your suggestions!
Last edited by canduc17; 07-14-2010 at 09:15 AM..
Reason: SOLVED!
In a "for i in *FD.CPY do" loop, I need to change .CPY to .layout so the executed command would be
reclay blahFD.CPY >blahFD.layout
What do I need to do to modify a copy of i to use after the > symbol?
TIA (5 Replies)
Hi All,
I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Hi, I have an N number of files in a directory. I like to write a shell script that would make identical plots for each one of these files.
The files have names such as:
t00001.dat
t00002.dat
t00003.dat
t00004.dat
t00005.dat
.
.
.
t00040.dat
i.e. the... (4 Replies)
Hello All,
Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....?
I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping
through a string containing some of these "Illegal Characters". Now... (5 Replies)
Hi guys, i have an executable file that contains several records and fields. One of the records has a variable filed that must be changed each time i want to execute the file. Would it be possible that i can use a loop to change the value of that field? Suppose that the field address is:
Record... (5 Replies)
I have a group of variables myLINEcnt1 - myLINEcnt10. I'm trying to printout the values using a for loop. I am at the head banging stage since i'm sure it has to be a basic syntax issue that i can't figure out.
For myIPgrp in 1 2 3 4 5 6 7 8 9 10; do
here i want to output the value of... (4 Replies)
Simple enough problem I think, I just can't seem to get it right.
The below doesn't work as intended, it's just a function defined in a much larger script:
CheckValues() {
for field in \
Group_ID \
Group_Title \
Rule_ID \
Rule_Severity \
... (2 Replies)
Hi to All,
Please find below details.
file_config.config
export file1_status="SUCCESS"
export file2_status="SUCCESS"
file_one.sh
I am calling another two shell script from these script. I need to pass individual two script status (If it's "FAILED") to file_main.sh.
file_main.sh
I... (2 Replies)
i am new to shell scripting. this is similar to the code which i was writing for some other work. i want the variable 'x' to have the value which it will finally have at the end of the loop ( the number of directories ). but the value of 'x' only changes inside the loop and it remains '0' out-side... (3 Replies)
Hello friends,
i wrote a script which includes a couple of if-else loops but i have to change it to while-do loop as it is not allowed to use "break" in if-else loop in bash.
#!/bin/bash -x
NUM=`find . -name ufsdump_output1.txt | xargs egrep "End-of-tape detected"`
if ; then echo "OK!"... (6 Replies)