Sponsored Content
Top Forums Shell Programming and Scripting Variable name change in a loop Post 302436884 by canduc17 on Tuesday 13th of July 2010 11:19:10 AM
Old 07-13-2010
Your example, scottn, works fine.
But my real case is a little bit more complicated...here a portion of it:
Code:
for I in UL_LAT UR_LAT LR_LAT LL_LAT UL_LON UR_LON LR_LON LL_LON ; do
            # Convert every value from 71 4 17.92 in 71.071644443
            DEGREES=$( echo ${I} | awk '{ print $1 }' )
            MINUTES=$( echo ${I} | awk '{ print $2 }' )
            SECOND=$(  echo ${I} | awk '{ print $3 }' )
            eval $I=$( echo "scale=9; ${DEGREES}+${MINUTES}/60+${SECOND}/3600" | bc )
        done

Executing that I obtain:
Code:
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: T
(standard_in) 1: syntax error
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: U
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: R
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: _
(standard_in) 1: illegal character: L
(standard_in) 1: illegal character: O
(standard_in) 1: illegal character: N
(standard_in) 1: syntax error

Any ideas?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

change if-else loop to while-do

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)
Discussion started by: EAGL€
6 Replies

2. Shell Programming and Scripting

Variable value dosent change after the loop changes it

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)
Discussion started by: chathura666
3 Replies

3. Shell Programming and Scripting

Change Variable Value from Multiple Scripts and Use these Variable

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)
Discussion started by: div_Neev
2 Replies

4. Shell Programming and Scripting

[SHELL: /bin/sh] For loop using variable variable names

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)
Discussion started by: Vryali
2 Replies

5. Shell Programming and Scripting

printing variable with variable suffix through loop

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)
Discussion started by: oly_r
4 Replies

6. Shell Programming and Scripting

Change a field value in a loop

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)
Discussion started by: saeed.soltani
5 Replies

7. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

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)
Discussion started by: mrm5102
5 Replies

8. Shell Programming and Scripting

Doing a loop to change a value in a file

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)
Discussion started by: lost.identity
4 Replies

9. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

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)
Discussion started by: danish0909
5 Replies

10. UNIX for Dummies Questions & Answers

Change argument in a for loop

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)
Discussion started by: wbport
5 Replies
MKMANIFEST(1)						      General Commands Manual						     MKMANIFEST(1)

NAME
mkmanifest - create a shell script to restore Unix filenames SYNOPSIS
mkmanifest [ files ] DESCRIPTION
Mkmanifest creates a shell script that will aid in the restoration of Unix filenames that got clobbered by the MSDOS filename restrictions. MSDOS filenames are restricted to 8 character names, 3 character extensions, upper case only, no device names, and no illegal characters. The mkmanifest program is compatible with the methods used in pcomm, arc, and mtools to change perfectly good Unix filenames to fit the MSDOS restrictions. EXAMPLE
I want to copy the following Unix files to a MSDOS diskette (using the mcopy command). very_long_name 2.many.dots illegal: good.c prn.dev Capital Mcopy will convert the names to: very_lon 2xmany.dot illegalx good.c xprn.dev capital The command: mkmanifest very_long_name 2.many.dots illegal: good.c prn.dev Capital > manifest would produce the following: mv very_lon very_long_name mv 2xmany.dot 2.many.dots mv illegalx illegal: mv xprn.dev prn.dev mv capital Capital Notice that "good.c" did not require any conversion, so it did not appear in the output. Suppose I've copied these files from the diskette to another Unix system, and I now want the files back to their original names. If the file "manifest" (the output captured above) was sent along with those files, it could be used to convert the filenames. SEE ALSO
arc(1), pcomm(1), mtools(1) local MKMANIFEST(1)
All times are GMT -4. The time now is 01:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy