Sponsored Content
Top Forums Shell Programming and Scripting ksh: How to store each output line into a different variable? Post 302255290 by radoulov on Thursday 6th of November 2008 06:53:04 AM
Old 11-06-2008
Code:
ifs="$IFS"
IFS='
'
set -A lines $(</tmp/generatelines.sh)
IFS="$ifs"

Then you have the lines in ${lines[0]} ... ${lines[n]}

And of course, if you have a line like:

Code:
a\nb

... and you want to display the element correctly,
you should use print -r.

Last edited by radoulov; 11-06-2008 at 08:02 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to store output in variable when put in background

Hi, How do I store following command output: export RESULT=`date` & It works when I do : export RESULT=`date` But what I need is when command put it background, I also need that output going to RESULT variable. Is there any way ? Thanks Sanjay (1 Reply)
Discussion started by: sanjay92
1 Replies

2. Shell Programming and Scripting

To store the output in a variable

Hi, I am getting the following error while executing the script. Please can someone throw some light where is the problem. Many thanks. ./check: temp: not found The directory related to SEP instance 4 does not exist. The script is as follows. SEP_APP="/scp/sepx/app... (2 Replies)
Discussion started by: Sudhakar333
2 Replies

3. Shell Programming and Scripting

How to store the sql query's output in a variable

Hi, My requirement is : We are calling an sql statement from a UNIX session, and fetching data into some variables from a table .. now we are unable to access these variables from outside the SQL part. Please let me know how can I achieve this. Can you please share a code snippet which... (4 Replies)
Discussion started by: venkatesh_sasi
4 Replies

4. Shell Programming and Scripting

remove column and store output to a variable

Hello guys I need to run a script to remove the last column of different comma separated files. The problem is that the number of columns of my files will be different and I won't know that number every time i run my script. Is there any command I can use to remove the last column without... (7 Replies)
Discussion started by: loperam
7 Replies

5. Shell Programming and Scripting

date output store in variable problem

When I run following command date Output1 => Thu Sep 9 03:26:52 IST 2010 When I store in a varibale as a=`date` echo $a output2 => Thu Sep 9 03:27:02 IST 2010 The differnece is, it is trimming the space when I am storing the output in varibale. Output1 = Thu Sep 9 03:26:52 IST 2010... (2 Replies)
Discussion started by: pravincpatil
2 Replies

6. Shell Programming and Scripting

store sqlplus output in variable

hi how can i store sqlplus output to a variable in sh script (not bash) Thanks MM (1 Reply)
Discussion started by: murtymvvs
1 Replies

7. Shell Programming and Scripting

How to read a file line by line and store it in a variable to execute a program ?

Hello, I am quite new in shell scripting and I would like to write a little scritp to run a program on some parameters files. all my parameters files are in the same directory, so pick them up with ls *.para >>dirafter that I have a dir file like that: param1.para param2.para etc... I... (2 Replies)
Discussion started by: shadok
2 Replies

8. Shell Programming and Scripting

how to store output to a variable

I need some help: 1) I have a out put from a shell script, the out put looks like this: Attempting privilege escalation using sudo ... List backups for CLTST: Start date Status Ret. Class Label -------------------- ------------ ------------ ... (2 Replies)
Discussion started by: samk
2 Replies

9. Shell Programming and Scripting

ksh : need to store the output of a awk command to a array

I have awk command : awk -F ' ' '{ print $NF }' log filename And it gives the output as below: 06:00:00 parameters: SDS (2) no no no no doc=4000000000). information: (6 Replies)
Discussion started by: ramprabhum
6 Replies

10. Programming

Python - store output of command to a variable

I am trying to store output of python command in variable. Could you please help how I can do that ? For example I am executing the following command - "CentOS" in server_desc The output would be True or False I would like to store the output in a variable say outPut and use condition... (4 Replies)
Discussion started by: atanubanerji
4 Replies
NUMDIFF(1)							   User Commands							NUMDIFF(1)

NAME
numdiff - compare similar files with numeric fields DESCRIPTION
Usage: numdiff -h|--help|-v|--version or numdiff [-s IFS][-a THRVAL[:RANGE|:RANGE1:RANGE2]][-r THRVAL[:RANGE|:RANGE1:RANGE2]][-2][-F NUM][-# NUM][-P][-N][-I][-c CURRNAME][-d C1C2][-t C1C2][-g N1N2][-p C1C2][-n C1C2][-e C1C2][-i C1C2][-X 1:RANGE][-X 2:RANGE][-E][-D][-b][-V][-O[NUM]][-q][-S][-z 1:RANGE][-z 2:RANGE][-Z 1:RANGE][-Z 2:RANGE][-m][-H][-f[NUM]][-T][-B][-l PATH][-o PATH] FILE1 FILE2 Compare putatively similar files line by line and field by field, ignoring small numeric differences or/and different numeric formats. RANGE, RANGE1 and RANGE2 stay for a positive integer value or for a range of integer values, like 1-, 3-5 or -7. The two arguments after the options are the names of the files to compare. The complete paths of the files should be given, a directory name is not accepted. The given paths cannot refer to the same file but one of them can be "-", which refers to stdin. Exit status: 1 if files differ, 0 if they are equal, -1 (255) in case of error -s, --separator=IFS Specify the set of characters to use to split the input lines into fields (The default set of characters is space, tab and newline). If IFS is prefixed with 1: or 2: then use the given character set only for the lines from the first or the second file respectively -a, --absolute-tolerance=THRVAL[:RANGE|:RANGE1:RANGE2] Set to THRVAL the maximum absolute difference permitted before that two numeric fields are regarded as different (The default value is zero). If a RANGE is given, use the specified threshold only when comparing fields whose positions lie in RANGE. If both RANGE1 and RANGE2 are given and have the same length, then use the specified threshold when comparing a field of FILE1 lying in RANGE1 with the corresponding field of FILE2 in RANGE2 -r, --relative-tolerance=THRVAL[:RANGE|:RANGE1:RANGE2] Set to THRVAL the maximum relative difference permitted before that two numeric fields are regarded as different (The default value is zero). If a RANGE is given, use the specified threshold only when comparing fields whose positions lie in RANGE. If both RANGE1 and RANGE2 are given and have the same length, then use the specified threshold when comparing a field of FILE1 lying in RANGE1 with the corresponding field of FILE2 in RANGE2 -2, --strict Consider two numerical values as equal only if both absolute and relative difference do not exceed the corresponding tolerance threshold -F, --formula=NUM Use the formula indicated by NUM to compute the relative errors. If 'NUM' is 0 use the classic formula. If 'NUM' is 1 compute the relative errors by considering the values in FILE1 as sample values. If 'NUM' is 2 compute the relative errors by considering the values in FILE2 as sample values. -#, --digits=NUM Set to NUM the number of digits in the significands used in multiple precision arithmetic -P, --positive-differences Ignore all differences due to numeric fields of the second file that are less than the corresponding numeric fields in the first file -N, --negative-differences Ignore all differences due to numeric fields of the second file that are greater than the corresponding numeric fields in the first file -I, --ignore-case Ignore changes in case while doing literal comparisons -c, --currency=CURRNAME Set to CURRNAME the currency name for the two files to compare. CURRNAME must be prefixed with 1: or 2: to specify the currency name only for the first or the second file -d, --decimal-point=C1C2 Specify the characters representing the decimal point in the two files to compare -t, --thousands-separator=C1C2 Specify the characters representing the thousands separator in the two files to compare -g, --group-length=N1N2 Specify the number of digits forming each group of thousands in the two files to compare -p, --plus-prefix=C1C2 Specify the (optional) prefixes for positive values used in the two files to compare -n, --minus-prefix=C1C2 Specify the prefixes for negative values used in the two files to compare -e, --exponent-letter=C1C2 Specify the exponent letters used in the two files to compare -i, --imaginary-unit=C1C2 Specify the characters representing the imaginary unit in the two files to compare -X, --exclude=1:RANGE Select the fields of the first file that have to be ignored -X, --exclude=2:RANGE Select the fields of the second file that have to be ignored -E, --essential While printing the differences between the two compared files show only the numerical ones -D, --dummy While printing the differences between the two compared files neglect all the numerical ones (dummy mode) -b, --brief Suppress all messages concerning the differences discovered in the structures of the two files -V, --verbose For every couple of lines which differ in at least one field print an header to show how these lines appear in the two compared files -O, --overview[=NUM] Display a side by side difference listing of the two files showing which lines are present only in one file, which lines are present in both files but with one or more differing fields, and which lines are identical. If 'NUM' is zero or is not specified, output at most 130 columns per line. If 'NUM' is a positive number, output at most 'NUM' columns per line. If 'NUM' is a negative number, do not output common lines and display at most -'NUM' columns per line. -q, --quiet, --silent Suppress all the standard output -S, --statistics Add some statistics to the standard output -z, --blur-if-numerical=1:RANGE Select the fields of the first file that have to be blurred during the synchronization procedure only if they turn out to be numeric -z, --blur-if-numerical=2:RANGE Select the fields of the second file that have to be blurred during the synchronization procedure only if they turn out to be numeric -Z, --blur-unconditionally=1:RANGE Select the fields of the first file that have to be unconditionally blurred during the synchronization procedure -Z, --blur-unconditionally=2:RANGE Select the fields of the second file that have to be unconditionally blurred during the synchronization procedure -m, --minimal During synchronization try hard to find a smaller set of changes -H, --speed-large-files During synchronization assume large files and many scattered small changes -f, --test-filter[=NUM] Run only the filter and then show the results of its attempt to synchronize the two files. If 'NUM' is zero or is not specified, output at most 130 columns per line. If 'NUM' is a positive number, output at most 'NUM' columns per line. If 'NUM' is a negative number, do not output common lines and display at most -'NUM' columns per line. -T, --expand-tabs Expand tabs to spaces in output while displaying the results of the synchronization procedure (meaningful only together with option -O or -f) -B, --binary Treat both files as binary files (only meaningful under Doz/Windoz) -l, --warnings-to=PATH Redirect warning and error messages from stderr to the indicated file -o, --output=PATH Redirect output from stdout to the indicated file -h, --help Show help message and predefined settings -v, --version Show version number, Copyright, Distribution Terms and NO-Warranty Default numeric format (for both files to compare): Currency name = "" Decimal point = `.' Thousands separator = `,' Number of digits in each thousands group = 3 Leading positive sign = `+' Leading negative sign = `-' Prefix for decimal exponent = `e' Symbol used to denote the imaginary unit = `i' COPYRIGHT
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Ivano Primi <ivprimi@libero.it> License GPLv3+: GNU GPL version 3 or later, see <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for numdiff is maintained as a Texinfo manual. If the info and numdiff programs are properly installed at your site, the command info numdiff should give you access to the complete manual. numdiff 5.6.0 January 2012 NUMDIFF(1)
All times are GMT -4. The time now is 05:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy