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
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT MOJAVE
strfmon_l
STRFMON(3) BSD Library Functions Manual STRFMON(3)
NAME
strfmon, strfmon_l -- convert monetary value to string
SYNOPSIS
#include <monetary.h>
ssize_t
strfmon(char *restrict s, size_t maxsize, const char *restrict format, ...);
#include <monetary.h>
#include <xlocale.h>
ssize_t
strfmon_l(char *restrict s, size_t maxsize, locale_t loc, const char *restrict format, ...);
DESCRIPTION
The strfmon() function places characters into the array pointed to by s, as controlled by the string pointed to by format. No more than
maxsize bytes are placed into the array.
While the strfmon() function uses the current locale, the strfmon_l() function may be passed a locale directly. See xlocale(3) for more
information.
The format string is composed of zero or more directives: ordinary characters (not %), which are copied unchanged to the output stream; and
conversion specifications, each of which results in fetching zero or more subsequent arguments. Each conversion specification is introduced
by the % character. After the %, the following appear in sequence:
o Zero or more of the following flags:
=f A '=' character followed by another character f which is used as the numeric fill character.
^ Do not use grouping characters, regardless of the current locale default.
+ Represent positive values by prefixing them with a positive sign, and negative values by prefixing them with a negative sign. This
is the default.
( Enclose negative values in parentheses.
! Do not include a currency symbol in the output.
- Left justify the result. Only valid when a field width is specified.
o An optional minimum field width as a decimal number. By default, there is no minimum width.
o A '#' sign followed by a decimal number specifying the maximum expected number of digits after the radix character.
o A '.' character followed by a decimal number specifying the number of digits after the radix character.
o One of the following conversion specifiers:
i The double argument is formatted as an international monetary amount.
n The double argument is formatted as a national monetary amount.
% A '%' character is written.
RETURN VALUES
If the total number of resulting bytes, including the terminating NULL byte, is not more than maxsize, strfmon() returns the number of bytes
placed into the array pointed to by s, not including the terminating NULL byte. Otherwise, -1 is returned, the contents of the array are
indeterminate, and errno is set to indicate the error.
ERRORS
The strfmon() function will fail if:
[E2BIG] Conversion stopped due to lack of space in the buffer.
[EINVAL] The format string is invalid.
[ENOMEM] Not enough memory for temporary buffers.
EXAMPLE
#include <stdio.h>
#include <monetary.h>
#include <locale.h>
int main() {
char buf[200];
setlocale(LC_ALL, "en_US");
(void)strfmon (buf, sizeof(buf)-1, "%n" , 123456.78);
printf("%s0, buf);
}
SEE ALSO
localeconv(3), xlocale(3)
STANDARDS
The strfmon() function conforms to IEEE Std 1003.1-2001 (``POSIX.1'').
AUTHORS
The strfmon() function was implemented by Alexey Zelkin <phantom@FreeBSD.org>.
This manual page was written by Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org> based on the standard's text.
BUGS
The strfmon() function does not correctly handle multibyte characters in the format argument.
BSD
October 12, 2002 BSD