Sponsored Content
Top Forums Shell Programming and Scripting Assign Values to a Variable in While Loop and Update the File Post 303017355 by Corona688 on Monday 14th of May 2018 03:44:06 PM
Old 05-14-2018
On a hunch, perhaps something like:
Code:
while IFS="|" read -r SERIAL JOB STATUS
do
        if [ condition ] 
        then
                STATUS="somethingelse"
        fi
        printf "%s|%s|%s\n" "$SERIAL" "$JOB" "$STATUS"
done < inputfile > outputfile

Note that inputfile and outputfile can't be the same.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read a file and assign the values to a variable

i have a file in this format curyymm PRVYYMM CDDMmmYY bddMmmyy eddMmmyy --------- ------- ------------ ---------- ----------- 0906 0905 09Jun09 01Jun09 30Jun09 ----------- --------- ------------ ------------ ----------- i need to read the... (5 Replies)
Discussion started by: depakjan
5 Replies

2. Shell Programming and Scripting

Read the csv file and assign the values in to variable

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)
Discussion started by: rajbal
11 Replies

3. Shell Programming and Scripting

Assign values to variable

Hi Masters, I want to assign the values of one variable to another variable. Here the varaible name 'var' is dynamic. I know the values of V_2 and U_3, but If the i/p of TYPE is 'U' and the NO is 3, then I want to assign the values of U_3 to var. How we can achieve it? TYPE="U"... (4 Replies)
Discussion started by: ecearund
4 Replies

4. Fedora

How to read a text file and assign the values in the same to a variable in loop

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)
Discussion started by: manishab00
1 Replies

5. UNIX for Advanced & Expert Users

How to read a text file and assign the values in the same to a variable in loop

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)
Discussion started by: manishab00
12 Replies

6. UNIX for Dummies Questions & Answers

How to assign values to variable in given scenario

Hi i have one variable like DIR="f1 f2" in config file in my script i have one runtime variable LFILE="DIR" now i want to use $DIR in my script by using LFILE that is i dont want to use DIR dirctly i am extracting DIR by some other means. Config file : DIR="f1 f2" Script: LFILE="DIR" i... (3 Replies)
Discussion started by: sriram_gec
3 Replies

7. Shell Programming and Scripting

Assign variable name through loop

Hi As bash does not support multidimensional arrays (?), I need some help with a problem. What I want to do is to assign variable names containing a counter in a loop . what I want to do is basically something like this: #!/bin/bash for i in {1..8}; do var$i = "some command" done... (6 Replies)
Discussion started by: Tobbev
6 Replies

8. Shell Programming and Scripting

Unable to read assign values to two variables in while loop

I am trying to read a input file which has two columns separated by space Input file server1 server2 server3 server4 server5 server6 When i execute the below while code it reads line by line and a and b variables are able to successfully fetch the values while read a b do echo "$a" echo... (5 Replies)
Discussion started by: chidori
5 Replies

9. Shell Programming and Scripting

Do While Loop + Read From File + assign line to a variable

Hello, I am using below code for reading from a file and assigning the values to a variable , but it is loosing the value after the loop , please suggest to retain the value of the variable after the loop , while IFS=: read -r line do set $dsc=$line echo 'printing line variable ' $line... (1 Reply)
Discussion started by: ParthThakkar
1 Replies

10. Shell Programming and Scripting

How to assign awk values to shell variable?

Hi Gurus, I have a script which assign awk output to shell variable. current it uses two awk command to assign value to two variables. I want to use one command to assign two values to two variables. I tried the code, but it does't work. kindly provide your suggestion. current code... (2 Replies)
Discussion started by: green_k
2 Replies
genxlt(1)						      General Commands Manual							 genxlt(1)

NAME
genxlt - Generates a codeset conversion table SYNOPSIS
genxlt [-f outputfile] [inputfile] OPTIONS
Specifies that the generated version of the codeset conversion table be placed in the file specified by outputfile. DESCRIPTION
The iconv subsystem can use either an algorithmic or a table converter to convert data from one codeset to another. The genxlt command cre- ates a table converter to be used by the iconv subsystem. The genxlt command reads a source codeset conversion table file from inputfile and writes the compiled version to outputfile. If inputfile is not specified, standard input is used. If outputfile is not specified, standard output is used. The source codeset conversion table file contains directives that are acted upon by the genxlt command to produce the compiled version. The format of a translation source file is as follows: Lines whose initial nonwhite-space character is the # (number sign) are treated as comment lines. Null lines and lines consisting only of white-space characters are treated as comment lines. Noncomment lines have to be of the following form: source target comment If source is found in the source codeset conversion table file multiple times, the last entry is used in the compilation of the translation table. The source and target arguments must be in the range of 0x00 through 0xff, inclusive; this restricts the table to 8-bit codesets. The con- version table must define all of the 256 possible source values; otherwise, processing the table results in an error. The following is an excerpt of a codeset conversion table: 0x80 0xc7 C cedilla 0x81 0xfc u diaeresis 0x82 0xe9 e acute 0x83 0xe2 a circumflex 0x84 0xe4 a diaeresis 0x85 0x40 a grave The name of the file generated by the genxlt command must use the following naming convention in order for the iconv subsystem to recognize the file as a valid converter. fromcode: "ISO8859-1-GL" tocode: "ISO8859-1" conversion table file: "ISO8859-1-GL_ISO8859-1" The conversion table file name is formed by concatenating the tocode file name onto the fromcode file name, with an underscore character between the two. The compiled conversion table must reside in the /usr/lib/nls/loc/iconvTable directory or, if the LOCPATH variable is defined, in an iconvTable directory subordinate to the LOCPATH directory. Otherwise, the iconv command does not find the table. Note The LOCPATH variable also overrides the default search path (/usr/lib/nls/loc) that is used to find locales. If this variable is defined, it must therefore specify a search path that application and system software can use to find both locales and converters. The LOCPATH vari- able is not defined by any standard, so use of the variable should be limited to testing locales or converters under development. EXIT STATUS
If successful, the genxlt command exits with a value of 0 (zero). If an unknown flag is detected, or the specified input file or output file cannot be opened, the genxlt command is unsuccessful and exits with a value of 1. If a syntax error is detected in the input stream, the genxlt command will exit immediately with a value of 2, and write to standard error the line numbers where the syntax error occurred. SEE ALSO
Commands: iconv(1) Functions: iconv(3) genxlt(1)
All times are GMT -4. The time now is 01:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy