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)						     Library Functions Manual						     localeconv(3)

NAME
localeconv - Retrieves locale-dependent formatting parameters LIBRARY
Standard C Library (libc) SYNOPSIS
#include <locale.h> struct lconv *localeconv(void); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: localeconv(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. DESCRIPTION
The localeconv() function provides access to the object that specifies the current locale's conventions for the format of numeric quanti- ties. The lconv structure contains values appropriate for formatting numeric quantities (monetary and otherwise) according to the rules of the current locale. The members of the structure with the type char * are pointers to strings, any of which (except decimal_point) can point to a null string, to indicate that the value is not available in the current locale or is of zero length. The members with type char are nonnegative numbers, any of which can be CHAR_MAX to indicate that the value is not available in the current locale. The members include the following: The decimal-point character used to format nonmonetary quantities. The separator for groups of digits to the left of the decimal point in formatted nonmonetary quantities. A string whose elements indicate the size of each group of digits in formatted nonmone- tary quantities. The international currency symbol applicable to the current locale. The first three characters of this value contain the alphabetic international currency symbol in accordance with those specified in ISO 4217:1987, Codes for the Representation of Currency and Funds. The fourth character (immediately preceding the null terminator) is the character used to separate the international currency symbol from the monetary quantity. The local currency symbol applicable to the current locale. The decimal point used to format monetary quanti- ties. The separator for groups of digits to the left of the decimal point in formatted monetary quantities. A string whose elements indi- cate the size of each group of digits in formatted monetary quantities. The string used to indicate a nonnegative, formatted monetary quantity. The string used to indicate a negative, formatted monetary quantity. The number of fractional digits (those to the right of the decimal point) to be displayed in an internationally formatted monetary quantity. The number of fractional digits (those to the right of the decimal point) to be displayed in a formatted monetary quantity. Set to 1 if the currency_symbol or int_curr_symbol precedes the value for a nonnegative, formatted monetary quantity. Set to 0 (zero) if the symbol succeeds the value. Set to 1 if the currency_symbol or int_curr_symbol is separated by a space from the value for a nonnegative formatted monetary quantity. Set to 0 (zero) if the symbol is not separated by a space from the value. Set to 2 if a space separates the symbol and the sign string, if adjacent. Set to 1 if he cur- rency_symbol or int_curr_symbol precedes the value for a negative, formatted monetary quantity. Set to 0 (zero) if the symbol succeeds the value. Set to 1 if the currency_symbol or int_curr_symbol is separated by a space from the value for a negative, formatted monetary quan- tity. Set to 0 (zero) if the symbol is not separated by a space from the value. Set to 2 if a space separates the symbol and the sign string, if adjacent. Set to a value that indicates the positioning of the positive_sign for a nonnegative, formatted monetary quantity. Set to a value that indicates the positioning of the negative_sign for a negative, formatted monetary quantity. [Tru64 UNIX] The left bracket used to display a negative, formatted monetary quantity. This is the locale's equivalent to the "(" (left parenthesis) used in the C locale and is used in conjunction with the right_parenthesis. [Tru64 UNIX] The right bracket used to display a negative, formatted mon- etary quantity. This is the locale's equivalent to the ")" (right parenthesis) used in the C locale and is used in conjunction with the left_parenthesis. The elements of grouping and mon_grouping are interpreted according to the following: No further grouping is to be performed. The previous element is to be repeatedly used for the remainder of the digits. The integer value is the number of digits that comprise the current group. The next element is examined to determine the size of the next group of digits to the left of the current group. The values of p_sign_posn and n_sign_posn are interpreted according to the following: Parentheses surround the quantity and currency_symbol or int_curr_symbol. The sign string precedes the quantity and currency_symbol or int_curr_symbol. The sign string succeeds the quantity and currency_symbol or int_curr_symbol. The sign string immediately precedes the currency_symbol or int_curr_symbol. The sign string immediately succeeds the currency_symbol or int_curr_symbol. RETURN VALUES
The localeconv() function returns a pointer to the filled-in object. The structure pointed to by the return value must not be modified by the program, but can be overwritten by a subsequent call to the localeconv() function. In addition, calls to the setlocale() function with categories LC_ALL, LC_MONETARY or LC_NUMERIC may overwrite the contents of the structure. No errors are defined for this function. RELATED INFORMATION
Functions: nl_langinfo(3), setlocale(3), strfmon(3) Others: i18n_intro(5), l10n_intro(5), standards(5) Writing Software for the International Market delim off localeconv(3)
All times are GMT -4. The time now is 02:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy