Sponsored Content
Top Forums Shell Programming and Scripting awk saving field of first file into array Post 302742319 by RozenKristal on Tuesday 11th of December 2012 01:02:31 AM
Old 12-11-2012
Thank you sir. Oh, how I flip the code so file 1 will go before file 2? The order how it goes is pretty important for me. Also, how do I make exception when the amount column doesnt have dollars sign, or 2 digits after decimal points to be ignored? That would make Euda to have $-12.45, not $-57.45

Last edited by RozenKristal; 12-11-2012 at 02:08 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

saving awk value in a bash array variable

hi all i am trying to save an awk value into an array in bash: total=`awk '{sum+=$3} END {print sum}' "$count".txt"` ((count++)) the above statement is in a while loop.. $count is to keep track of file numbers (1.txt,2.txt,3.txt,etc.) i get the following error: ./lines1:... (1 Reply)
Discussion started by: npatwardhan
1 Replies

2. Shell Programming and Scripting

saving values from awk expression into shell array

hi i am trying to save the values i extract from a file with the help of awk in a bash shell array. i have: exec 10<file2 while read LINE <&10; do ARRAY1=$(awk '{print $1}' file2) ((count++)) done echo ${ARRAY1} it prints just blank lines. file1 has two columns and i... (4 Replies)
Discussion started by: npatwardhan
4 Replies

3. Shell Programming and Scripting

saving values in file in an array in awk

hi i am trying to save values in a file in an array in awk..the file is as follows: 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0, so far i have this: awk 'BEGIN {RS="\n";FS=","} { for(i=1;i<=NR;i++) { for(j=1;j<=NF;j++) { a=$j; } } (4 Replies)
Discussion started by: npatwardhan
4 Replies

4. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

5. Shell Programming and Scripting

Saving file content in arrays using AWK

Hi, im new to shell scripting. i have a query for which i have searched your forums but coulndt get what i need. i have a file that has two records of exactly the same length and format and they are comma seperated. i need to save the first and the second columns of the input file to 2 different... (11 Replies)
Discussion started by: atikan
11 Replies

6. Shell Programming and Scripting

awk assign output of array to specific field-number

With this script i want to print the output to a specific field-number . Can anybody help? awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv 4 135 5 185 6 85 11 30input_6.csv 1 90 3 58 4 135 7 60 8 55 10... (1 Reply)
Discussion started by: sdf
1 Replies

7. Shell Programming and Scripting

How to split file into multiple files using awk based on 1 field in the file?

Good day all I need some helps, say that I have data like below, each field separated by a tab DATE NAME ADDRESS 15/7/2012 LX a.b.c 15/7/2012 LX1 a.b.c 16/7/2012 AB a.b.c 16/7/2012 AB2 a.b.c 15/7/2012 LX2 a.b.c... (2 Replies)
Discussion started by: alexyyw
2 Replies

8. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

9. Shell Programming and Scripting

awk to print array that occurs the most with matching value in another field

In the below awk I am splitting $7 on the : and then counting each line or NM_xxxx. If the $1 value is the same for each line then print the $7 that occurs the most with the matching $1 value. The awk seems close but I am not sure what is going on. I included a description as well as to what I... (1 Reply)
Discussion started by: cmccabe
1 Replies

10. UNIX for Beginners Questions & Answers

awk Associative Array and/or Referring to Field by String (Nonconstant String Value)

I will start with an example of what I'm trying to do and then describe how I am approaching the issue. File PS028,005 Lexeme HRS # M # PhraseType 1(1:1) 7(7) PhraseLab 501 503 ClauseType ZYq0 PS028,005 Lexeme W # L> # BNH # M #... (17 Replies)
Discussion started by: jvoot
17 Replies
ECVT(3) 						   BSD Library Functions Manual 						   ECVT(3)

NAME
ecvt, fcvt, gcvt -- convert double to ASCII string SYNOPSIS
#include <stdlib.h> char * ecvt(double value, int ndigit, int * restrict decpt, int * restrict sign); char * fcvt(double value, int ndigit, int * restrict decpt, int * restrict sign); char * gcvt(double value, int ndigit, char *buf); DESCRIPTION
These functions are provided for compatibility with legacy code. New code should use the snprintf(3) function for improved safety and porta- bility. The ecvt(), fcvt() and gcvt() functions convert the double precision floating-point number value to a NUL-terminated ASCII string. The ecvt() function converts value to a NUL-terminated string of exactly ndigit digits and returns a pointer to that string. The result is padded with zeroes from left to right as needed. There are no leading zeroes unless value itself is 0. The least significant digit is rounded in an implementation-dependent manner. The position of the decimal point relative to the beginning of the string is stored in decpt. A negative value indicates that the decimal point is located to the left of the returned digits (this occurs when there is no whole number component to value). If value is zero, it is unspecified whether the integer pointed to by decpt will be 0 or 1. The decimal point itself is not included in the returned string. If the sign of the result is negative, the integer pointed to by sign is non-zero; otherwise, it is 0. If the converted value is out of range or is not representable, the contents of the returned string are unspecified. The fcvt() function is identical to ecvt() with the exception that ndigit specifies the number of digits after the decimal point (zero-padded as needed). The gcvt() function converts value to a NUL-terminated string similar to the %g printf(3) format specifier and stores the result in buf. It produces ndigit significant digits similar to the %f printf(3) format specifier where possible. If ndigit does allow sufficient precision, the result is stored in exponential notation similar to the %e printf(3) format specifier. If value is less than zero, buf will be prefixed with a minus sign. A decimal point is included in the returned string if value is not a whole number. Unlike the ecvt() and fcvt() func- tions, buf is not zero-padded. RETURN VALUES
The ecvt(), fcvt() and gcvt() functions return a NUL-terminated string representation of value. WARNINGS
The ecvt() and fcvt() functions return a pointer to internal storage space that will be overwritten by subsequent calls to either function. The maximum possible precision of the return value is limited by the precision of a double and may not be the same on all architectures. The snprintf(3) function is preferred over these functions for new code. SEE ALSO
printf(3), strtod(3) STANDARDS
The ecvt(), fcvt() and gcvt() functions conform to IEEE Std 1003.1-2001 (``POSIX.1''). BSD
December 1, 2002 BSD
All times are GMT -4. The time now is 07:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy