Sponsored Content
Top Forums Shell Programming and Scripting reading variable value from a file Post 302365809 by ahmad.diab on Wednesday 28th of October 2009 05:50:48 AM
Old 10-28-2009

nawk -F"(=| )" '
(FNR==NR){a[$1]=$2 ; next}
{r=($1 in a) ?  $1"-->"a[$1] :  $1 ; print r}
' b.txt a.txt


10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading file and assigning that to Variable

I am missing something here, I have a file which contains only one line and that is either a number or character string. I am trying to read the file and assign that value to a variable and here it seems I am missing something and not getting the expected results... Here is the code : #!/bin/ksh... (2 Replies)
Discussion started by: Vaddadi
2 Replies

2. Shell Programming and Scripting

Reading variable from file variable values

Hi, Here is the output of lpstat. I would like to read value of Queue which is(abxxxxb1)and status that is DOWN in first line. i dont care what is in second line. any one can help me.thanks Queue Dev Status Job Files User PP % Blks Cp Rnk ------- ----- ---------... (5 Replies)
Discussion started by: sagii
5 Replies

3. Shell Programming and Scripting

How to get the modified value of variable outside the while loop reading from a file

Hi Friends , Sorry if this is a repeated question , The input file contains 5 lines , so the the values of the variables i and count should b i=5; count=15 but the variables are not updating , the value of variables showing i=0 and count =0 only.:mad: can any1 help me please. (11 Replies)
Discussion started by: babusek
11 Replies

4. Shell Programming and Scripting

reading the whole line from a file into a variable

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

5. UNIX for Dummies Questions & Answers

Reading a variable from file

Hi, I have a situation where I need to read a variable from another file. But the problem is that the variable in the other file is starting with $. E.g. file1: $var1=out temp_ss.sh: . file1 echo "Print : $var1" It works fine if the file1 is having var1=out (note that it is... (6 Replies)
Discussion started by: shash
6 Replies

6. Shell Programming and Scripting

Reading a file with while into variable and using in another process

I would appreciate some help, please. I have a file cutshellb.txt, which contains four report names (but it could be any number from 1 to x. The report suffix is not necessarily consecutive: report3785 report3786 report3787 report3788 I have a shell script which attempts to read the... (3 Replies)
Discussion started by: Dicloflex
3 Replies

7. Shell Programming and Scripting

Reading a variable from parameter file

HI all, I have a parameter file with entries like $$Name =Abhinav $$CUTOFF_DATE = 11/11/2209 I am reading a variable from this file using a awk command like : var2=`awk -F"" "/CUTOFF_DATE/{f=$1;}{print f;}" InputFIleName` but facing an error like awk: cmd. line:1:... (3 Replies)
Discussion started by: abhinav192
3 Replies

8. Shell Programming and Scripting

Reading from a file and storing it in a variable

Hi folks, I'm using bash and would like to do the following. I would like to read some values from the file and store it in the variable and use it. My file is 1.txt and its contents are VERSION=5.6 UPDATE=4 I would like to read "5.6" and "4" and store it in a variable in shell... (6 Replies)
Discussion started by: scriptfriend
6 Replies

9. Shell Programming and Scripting

Reading from a File and Using as an Input variable

I need to know how the the string constant from Input File should be read and provide as input data for the script . INPUT FILE CONST VARIABLE myname=/root/dir/syslog/myname1 myname=/root/dir/syslog/myname2 myname=/root/dir/syslog/myname3 urname=/root/dir/syslog/urname1... (6 Replies)
Discussion started by: baraghun
6 Replies

10. Shell Programming and Scripting

Trouble reading content of file from a variable

Hi , i have a parameter which has path of a file. Now i need to have another parameter with the content of that file. I tried the belwo script , can any one please help. I dont want to use cat command to read. Can we do it with out using cat command. while read line do... (9 Replies)
Discussion started by: Ravindra Swan
9 Replies
dos2unix(1)						      General Commands Manual						       dos2unix(1)

dos2unix - DOS/MAC to UNIX text file format converter SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates dos2unix under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. dos2unix Convert and replace a.txt. Convert and replace b.txt. dos2unix a.txt b.txt dos2unix -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format. dos2unix a.txt -c iso b.txt dos2unix -c ascii a.txt -c iso b.txt dos2unix -c mac a.txt b.txt Convert and replace a.txt while keeping original date stamp. dos2unix -k a.txt dos2unix -k -o a.txt Convert a.txt and write to e.txt. dos2unix -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. dos2unix -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. dos2unix a.txt -n b.txt e.txt dos2unix -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org> MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
unix2dos(1) mac2unix(1) 1995.03.31 dos2unix v3.0 dos2unix(1)

Featured Tech Videos

All times are GMT -4. The time now is 04:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy