Sponsored Content
Top Forums Shell Programming and Scripting awk Index to get position matches pattern Post 303008398 by Don Cragun on Friday 1st of December 2017 03:02:02 AM
Old 12-01-2017
Do you really want to truncate the contents of the newly created 3rd field if input field 2 contains more than 47 characters?

Why is the 2nd awk script in your pipeline looking for the currency values in field 3 when the currency values, if present, will be in field 4 by then?

Please explain exactly what the format is for the "decimal" and "decimal & Currency" strings. Will that field always be empty if a monetary amount is not present? Do there really have to be at least two digits in a monetary amount? Should a decimal point be required in a monetary amount? If a decimal point is present in a monetary amount, should there be a required number of decimal digits after that decimal point? Are there minimum and maximum numbers of uppercase letters in a currency code?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to select lines in unix matches a pattern at a particular position

I have huge file. I want to copy the lines which have first character as 2 or 7, and also which has fist two characters as 90. I need only these records from file. How I can acheive this. Can somebody help me..... (2 Replies)
Discussion started by: cs_banda
2 Replies

2. Shell Programming and Scripting

How to awk/sed/grep lines which contains a pattern at a given position

Dear friends I am new to linux and was trying to split some files userwise in our linux server. I have a data file of 156 continuous columns named ecscr final. I want the script to redirect all the lines containing a pattern of 7 digits to separate files. I was using grep to do that,... (2 Replies)
Discussion started by: anoopvraj
2 Replies

3. Shell Programming and Scripting

awk to count pattern matches

i have an awk statement which i am using to count the number of occurences of the number ,5, in the file: awk '/,5,/ {count++}' TRY.txt | awk 'END { printf(" Total parts: %d",count)}' i know there is a total of 10 matches..what is wrong here? thanks (16 Replies)
Discussion started by: npatwardhan
16 Replies

4. Shell Programming and Scripting

awk to sum specific field when pattern matches

Trying to sum field #6 when field #2 matches string as follows: Input data: 2010-09-18-20.24.44.206117 UOWEXEC db2bp DB2XYZ hostname 1 2010-09-18-20.24.44.206117 UOWWAIT db2bp DB2XYZ hostname ... (3 Replies)
Discussion started by: ux4me
3 Replies

5. Shell Programming and Scripting

Remove text from n position to n position sed/awk

I want to remove text from nth position to nth position couple of times in same line my line is "hello is there anyone can help me with this question" I need like this ello is there anyone can help me with question 'h' is removed and 'this' removed from the line. I want to do this... (5 Replies)
Discussion started by: elamurugu
5 Replies

6. Shell Programming and Scripting

awk pattern search with inconsistent position

Hi, Anybody knows how to get the value after the regexp and test it on pattern? The if the pattern matches, it will print the entire line on a separate file. Here's my raw file: ^_Name^_string^_Apple ^_Color^_string^_Red ^_Code^_string^_121 ^_Name^_string^_Banana ^_Code^_string^_123 ... (7 Replies)
Discussion started by: Jin_
7 Replies

7. Shell Programming and Scripting

awk with range but matches pattern

To match range, the command is: awk '/BEGIN/,/END/' but what I want is the range is printed only if there is additional pattern that matches in the range itself? maybe like this: awk '/BEGIN/,/END/ if only in that range there is /pattern/' Thanks (8 Replies)
Discussion started by: zorrox
8 Replies

8. Shell Programming and Scripting

How to get index values for multiple matches in the same line with awk?

Hi, I know that echo "bob alice robert alice" | awk '{print index($0,"alice")}' 5Will output the index of the first alice match, is there any way to get the index of all matches?, eg: echo "bob alice robert alice" | awk 'unknown magic' 5:18Thanks for your time. (6 Replies)
Discussion started by: chilicuil
6 Replies

9. Shell Programming and Scripting

Number of matches and matched pattern(s) in awk

input: !@#$%2QW5QWERTAB$%^&* The string above is not separated (or FS=""). For clarity sake one could re-write the string by including a "|" as FS as follow: !|@|#|$|%|2QW|5QWERT|A|B|$|%|^|&|* Here, I am only interested in patterns (their numbers are variable between records) containing... (16 Replies)
Discussion started by: beca123456
16 Replies

10. UNIX for Beginners Questions & Answers

find pattern matches in consecutive lines in certain fields-awk

I have a text file with many thousands of lines, a small sample of which looks like this: InputFile:PS002,003 D -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 6 -1 -1 -1 -1 0 509 0 PS002,003 PSQ 0 1 7 18 1 0 -1 1 1 3 -1 -1 ... (5 Replies)
Discussion started by: jvoot
5 Replies
LOCALECONV(3)						   BSD Library Functions Manual 					     LOCALECONV(3)

NAME
localeconv, localeconv_l -- natural language formatting for C LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <locale.h> struct lconv * localeconv(void); #include <xlocale.h> struct lconv * localeconv_l(locale_t loc); DESCRIPTION
The localeconv() function returns a pointer to a structure which provides parameters for formatting numbers, especially currency values: struct lconv { char *decimal_point; char *thousands_sep; char *grouping; char *int_curr_symbol; char *currency_symbol; char *mon_decimal_point; char *mon_thousands_sep; char *mon_grouping; char *positive_sign; char *negative_sign; char int_frac_digits; char frac_digits; char p_cs_precedes; char p_sep_by_space; char n_cs_precedes; char n_sep_by_space; char p_sign_posn; char n_sign_posn; char int_p_cs_precedes; char int_n_cs_precedes; char int_p_sep_by_space; char int_n_sep_by_space; char int_p_sign_posn; char int_n_sign_posn; }; The individual fields have the following meanings: decimal_point The decimal point character, except for currency values, cannot be an empty string. thousands_sep The separator between groups of digits before the decimal point, except for currency values. grouping The sizes of the groups of digits, except for currency values. This is a pointer to a vector of integers, each of size char, representing group size from low order digit groups to high order (right to left). The list may be terminated with 0 or CHAR_MAX. If the list is terminated with 0, the last group size before the 0 is repeated to account for all the dig- its. If the list is terminated with CHAR_MAX, no more grouping is performed. int_curr_symbol The standardized international currency symbol. currency_symbol The local currency symbol. mon_decimal_point The decimal point character for currency values. mon_thousands_sep The separator for digit groups in currency values. mon_grouping Like grouping but for currency values. positive_sign The character used to denote nonnegative currency values, usually the empty string. negative_sign The character used to denote negative currency values, usually a minus sign. int_frac_digits The number of digits after the decimal point in an international-style currency value. frac_digits The number of digits after the decimal point in the local style for currency values. p_cs_precedes 1 if the currency symbol precedes the currency value for nonnegative values, 0 if it follows. p_sep_by_space 1 if a space is inserted between the currency symbol and the currency value for nonnegative values, 0 otherwise. n_cs_precedes Like p_cs_precedes but for negative values. n_sep_by_space Like p_sep_by_space but for negative values. p_sign_posn The location of the positive_sign with respect to a nonnegative quantity and the currency_symbol, coded as follows: 0 Parentheses around the entire string. 1 Before the string. 2 After the string. 3 Just before currency_symbol. 4 Just after currency_symbol. n_sign_posn Like p_sign_posn but for negative currency values. int_p_cs_precedes Same as p_cs_precedes, but for internationally formatted monetary quantities. int_n_cs_precedes Same as n_cs_precedes, but for internationally formatted monetary quantities. int_p_sep_by_space Same as p_sep_by_space, but for internationally formatted monetary quantities. int_n_sep_by_space Same as n_sep_by_space, but for internationally formatted monetary quantities. int_p_sign_posn Same as p_sign_posn, but for internationally formatted monetary quantities. int_n_sign_posn Same as n_sign_posn, but for internationally formatted monetary quantities. Unless mentioned above, an empty string as a value for a field indicates a zero length result or a value that is not in the current locale. A CHAR_MAX result similarly denotes an unavailable value. While the localeconv() function uses the current locale, the localeconv_l() function may be passed a locale directly. See xlocale(3) for more information. RETURN VALUES
The localeconv() function returns a pointer to a static object which may be altered by later calls to setlocale(3) or localeconv(). ERRORS
No errors are defined. SEE ALSO
setlocale(3), strfmon(3), xlocale(3) STANDARDS
The localeconv() function conforms to ISO/IEC 9899:1999 (``ISO C99''). HISTORY
The localeconv() function first appeared in 4.4BSD. BSD
November 21, 2003 BSD
All times are GMT -4. The time now is 02:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy