Sponsored Content
Top Forums Shell Programming and Scripting awk remove/grab lines from file with pattern from other file Post 302966349 by RudiC on Thursday 11th of February 2016 04:09:00 AM
Old 02-11-2016
This might solve your new problem:
Code:
awk -F ';' '
NR==FNR         {id[$0]
                 next
                }
                {for (SP in id) if ($0 ~ SP)    {print > "Positive"    
                                                 next
                                                }
                }
                {print > "Negative"    
                }
' file1 file2
cf *ive
Negative:
37760   Haushalt & Küche > SodaStream & Wassermaxx > Sirup      SodaStream Orange Sirup 500ml   3.1682242990654 EUR     7.00    SodaStream      7290002793335   1020103490      >10     4.99    0.699   0       Haushalt & Kueche > SodaStream & Wassermaxx > Sirup
37761   Haushalt & Küche > SodaStream & Wassermaxx > Sirup      SodaStream Zitrone-Limette Sirup 500ml  2.5046728971963 EUR     7.00    SodaStream      7290002793328   1020110490      0       4.99    0.600   0       Haushalt & Kueche > SodaStream & Wassermaxx > Sirup
37762   Haushalt & Küche > SodaStream & Wassermaxx > Sirup      SodaStream Apfel-Mix Sirup 500ml        3.5046728971963 EUR     7.00    SodaStream      7290002793229   1020108491      3       4.99    0.600   0       Haushalt & Kueche > SodaStream & Wassermaxx > Sirup
37765   Haushalt & Küche > SodaStream & Wassermaxx > Sirup      SodaStream Isotonic Sirup 375ml 3.7289719626168 EUR     7.00    SodaStream      7290010498574   5140013 >10     4.99    0.400   0       Haushalt & Kueche > SodaStream & Wassermaxx > Sirup
37773   Haushalt & Küche > Elektro Kleingeräte > Eierkocher     Gastroback 42801 Design Eierkocher Silber       33      EUR     19.00   Gastroback      4016432428011   0580178 1       0       1.000   0       Haushalt & Kueche > Elektro Kleingeraete > Eierkocher
54164           Logitech R400 Wireless Presenter        29.327731092437 EUR     19.00   Logitech        5099206018129   910-001357      2       4.99    0.210   0
Positive:
68132   Computer & Zubehör > Eingabegeräte > Mäuse      Logitech MK710 Wireless Desktop 64.621848739496 EUR     19.00   Logitech        5099206020948   920-002420      10      4.99    1.390   0       Computer & Zubehoer > Eingabegeraete > Maeuse

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search file for pattern and grab some lines before pattern

I want to search a file for a string and then if the string is found I need the line that the string is on - but also the previous two lines from the file (that the pattern will not be found in) This is on solaris Can you help? (2 Replies)
Discussion started by: frustrated1
2 Replies

2. Shell Programming and Scripting

shell script to remove all lines from a file before a line starting with pattern

hi,, i hav a file with many lines.i need to remove all lines before a line begginning with a specific pattern from the file because these lines are not required. Can u help me out with either a perl script or shell script example:- if file initially contains lines: a b c d .1.2 d e f... (2 Replies)
Discussion started by: raksha.s
2 Replies

3. Shell Programming and Scripting

Getting lines before and until next pattern in file /awk, sed

Hi, I need to get specific parts in a large file. I need to: Get a line containing an IP address, and read from there to another line saying ***SNMP-END*** So, I have the start and the end well defined, but the problem is that apparently the awk command using the -F option doesn't work... (17 Replies)
Discussion started by: ocramas
17 Replies

4. Shell Programming and Scripting

How to grab a block of data in a file with repeating pattern?

I need to send email to receipient in each block of data in a file which has the sender address under TO and just send that block of data where it ends as COMPANY. I tried to work this out by getting line numbers of the string HELLO but unable to grab the next block of data to send the next... (5 Replies)
Discussion started by: loggedout
5 Replies

5. UNIX for Dummies Questions & Answers

awk -remove pattern from file

I have a file like this - I want to remove the 2015 (or any four digit #) from column $4 so I can get: Nov 05 1997 /ifs/inventory2/ for example. Im not sure how. Should I use an if statement with awk? Jan 16 2015 23:45 /ifs/sql_file Jan 16 2015 23:45 /ifs/sql_file Nov 05 2015 1997... (4 Replies)
Discussion started by: newbie2010
4 Replies

6. Shell Programming and Scripting

awk to remove lines in file if specific field matches

I am trying to remove lines in the target.txt file if $5 before the - in that file matches sorted_list. I have tried grep and awk. Thank you :). grep grep -v -F -f targets.bed sort_list grep -vFf sort_list targets awk awk -F, ' > FILENAME == ARGV {to_remove=1; next} > ! ($5 in... (2 Replies)
Discussion started by: cmccabe
2 Replies

7. Shell Programming and Scripting

Using awk to remove lines from file that match text

I am trying to remove each line in which $2 is FP or RFP. I believe the below will remove one instance but not both. Thank you :). file 12 123 FP 11 10 RFP awk awk -F'\t' ' $2 != "FP"' file desired output 12 11 (6 Replies)
Discussion started by: cmccabe
6 Replies

8. UNIX for Beginners Questions & Answers

awk function to remove lines that contain contents of another file

Hi, I'd be grateful for your help with the following. I have a file (file.txt) with 10 columns and about half a million lines, which in simplified form looks like this: ID Col1 Col2 Col3.... a 4 2 8 b 5 6 1 c 8 4 1 d... (4 Replies)
Discussion started by: aberg
4 Replies

9. UNIX for Beginners Questions & Answers

awk to remove pattern and lines above pattern

In the awk below I am trying to remove all lines above and including the pattern Test or Test2. Each block is seperated by a newline and Test2 also appears in the lines to keep but it will always have additional text after it. The Test to remove will not. The awk executed until the || was added... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Beginners Questions & Answers

awk with sed to combine lines and remove specific odd # pattern from line

In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line... (4 Replies)
Discussion started by: cmccabe
4 Replies
LOCALECONV(3P)						     POSIX Programmer's Manual						    LOCALECONV(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
localeconv -- return locale-specific information SYNOPSIS
#include <locale.h> struct lconv *localeconv(void); DESCRIPTION
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2008 defers to the ISO C standard. The localeconv() function shall set the components of an object with the type struct lconv with the values appropriate for the formatting of numeric quantities (monetary and otherwise) according to the rules of the current locale. The members of the structure with type char * are pointers to strings, any of which (except decimal_point) can point to "", to indicate that the value is not available in the current locale or is of zero length. The members with type char are non-negative 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: char *decimal_point The radix character used to format non-monetary quantities. char *thousands_sep The character used to separate groups of digits before the decimal-point character in formatted non-monetary quantities. char *grouping A string whose elements taken as one-byte integer values indicate the size of each group of digits in formatted non-monetary quanti- ties. char *int_curr_symbol The international currency symbol applicable to the current locale. The first three characters contain the alphabetic international currency symbol in accordance with those specified in the ISO 4217:2001 standard. The fourth character (immediately preceding the null byte) is the character used to separate the international currency symbol from the monetary quantity. char *currency_symbol The local currency symbol applicable to the current locale. char *mon_decimal_point The radix character used to format monetary quantities. char *mon_thousands_sep The separator for groups of digits before the decimal-point in formatted monetary quantities. char *mon_grouping A string whose elements taken as one-byte integer values indicate the size of each group of digits in formatted monetary quantities. char *positive_sign The string used to indicate a non-negative valued formatted monetary quantity. char *negative_sign The string used to indicate a negative valued formatted monetary quantity. char int_frac_digits The number of fractional digits (those after the decimal-point) to be displayed in an internationally formatted monetary quantity. char frac_digits The number of fractional digits (those after the decimal-point) to be displayed in a formatted monetary quantity. char p_cs_precedes Set to 1 if the currency_symbol precedes the value for a non-negative formatted monetary quantity. Set to 0 if the symbol succeeds the value. char p_sep_by_space Set to a value indicating the separation of the currency_symbol, the sign string, and the value for a non-negative formatted monetary quantity. char n_cs_precedes Set to 1 if the currency_symbol precedes the value for a negative formatted monetary quantity. Set to 0 if the symbol succeeds the value. char n_sep_by_space Set to a value indicating the separation of the currency_symbol, the sign string, and the value for a negative formatted monetary quantity. char p_sign_posn Set to a value indicating the positioning of the positive_sign for a non-negative formatted monetary quantity. char n_sign_posn Set to a value indicating the positioning of the negative_sign for a negative formatted monetary quantity. char int_p_cs_precedes Set to 1 or 0 if the int_curr_symbol respectively precedes or succeeds the value for a non-negative internationally formatted mone- tary quantity. char int_n_cs_precedes Set to 1 or 0 if the int_curr_symbol respectively precedes or succeeds the value for a negative internationally formatted monetary quantity. char int_p_sep_by_space Set to a value indicating the separation of the int_curr_symbol, the sign string, and the value for a non-negative internationally formatted monetary quantity. char int_n_sep_by_space Set to a value indicating the separation of the int_curr_symbol, the sign string, and the value for a negative internationally for- matted monetary quantity. char int_p_sign_posn Set to a value indicating the positioning of the positive_sign for a non-negative internationally formatted monetary quantity. char int_n_sign_posn Set to a value indicating the positioning of the negative_sign for a negative internationally formatted monetary quantity. The elements of grouping and mon_grouping are interpreted according to the following: {CHAR_MAX} No further grouping is to be performed. 0 The previous element is to be repeatedly used for the remainder of the digits. other 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 before the current group. The values of p_sep_by_space, n_sep_by_space, int_p_sep_by_space, and int_n_sep_by_space are interpreted according to the following: 0 No space separates the currency symbol and value. 1 If the currency symbol and sign string are adjacent, a space separates them from the value; otherwise, a space separates the currency symbol from the value. 2 If the currency symbol and sign string are adjacent, a space separates them; otherwise, a space separates the sign string from the value. For int_p_sep_by_space and int_n_sep_by_space, the fourth character of int_curr_symbol is used instead of a space. The values of p_sign_posn, n_sign_posn, int_p_sign_posn, and int_n_sign_posn are interpreted according to the following: 0 Parentheses surround the quantity and currency_symbol or int_curr_symbol. 1 The sign string precedes the quantity and currency_symbol or int_curr_symbol. 2 The sign string succeeds the quantity and currency_symbol or int_curr_symbol. 3 The sign string immediately precedes the currency_symbol or int_curr_symbol. 4 The sign string immediately succeeds the currency_symbol or int_curr_symbol. The implementation shall behave as if no function in this volume of POSIX.1-2008 calls localeconv(). The localeconv() function need not be thread-safe. RETURN VALUE
The localeconv() function shall return a pointer to the filled-in object. The application shall not modify the structure to which the return value points, nor any storage areas pointed to by pointers within the structure. The returned pointer, and pointers within the structure, might be invalidated or the structure or the storage areas might be overwritten by a subsequent call to localeconv(). In addi- tion, the returned pointer, and pointers within the structure, might be invalidated or the structure or the storage areas might be over- written by subsequent calls to setlocale() with the categories LC_ALL, LC_MONETARY, or LC_NUMERIC, or by calls to uselocale() which change the categories LC_MONETARY or LC_NUMERIC. ERRORS
No errors are defined. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
The following table illustrates the rules which may be used by four countries to format monetary quantities. +------------+-----------------+-----------------+----------------------+ | Country | Positive Format | Negative Format | International Format | +------------+-----------------+-----------------+----------------------+ |Italy | EUR.1.230 | -EUR.1.230 | EUR.1.230 | |Netherlands | EUR 1.234,56 | EUR -1.234,56 | EUR 1.234,56 | |Norway | kr1.234,56 | kr1.234,56- | NOK 1.234,56 | |Switzerland | SFrs.1,234.56 | SFrs.1,234.56C | CHF 1,234.56 | +------------+-----------------+-----------------+----------------------+ For these four countries, the respective values for the monetary members of the structure returned by localeconv() are: +-------------------+--------+-------------+--------+-------------+ | | Italy | Netherlands | Norway | Switzerland | +-------------------+--------+-------------+--------+-------------+ |int_curr_symbol | "EUR." | "EUR " | "NOK " | "CHF " | |currency_symbol | "EUR." | "EUR" | "kr" | "SFrs." | |mon_decimal_point | "" | "," | "," | "." | |mon_thousands_sep | "." | "." | "." | "," | |mon_grouping | "3" | "3" | "3" | "3" | |positive_sign | "" | "" | "" | "" | |negative_sign | "-" | "-" | "-" | "C" | |int_frac_digits | 0 | 2 | 2 | 2 | |frac_digits | 0 | 2 | 2 | 2 | |p_cs_precedes | 1 | 1 | 1 | 1 | |p_sep_by_space | 0 | 1 | 0 | 0 | |n_cs_precedes | 1 | 1 | 1 | 1 | |n_sep_by_space | 0 | 1 | 0 | 0 | |p_sign_posn | 1 | 1 | 1 | 1 | |n_sign_posn | 1 | 4 | 2 | 2 | |int_p_cs_precedes | 1 | 1 | 1 | 1 | |int_n_cs_precedes | 1 | 1 | 1 | 1 | |int_p_sep_by_space | 0 | 0 | 0 | 0 | |int_n_sep_by_space | 0 | 0 | 0 | 0 | |int_p_sign_posn | 1 | 1 | 1 | 1 | |int_n_sign_posn | 1 | 4 | 4 | 2 | +-------------------+--------+-------------+--------+-------------+ RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
fprintf(), fscanf(), isalpha(), isascii(), nl_langinfo(), setlocale(), strcat(), strchr(), strcmp(), strcoll(), strcpy(), strftime(), strlen(), strpbrk(), strspn(), strtok(), strxfrm(), strtod(), uselocale() The Base Definitions volume of POSIX.1-2008, <langinfo.h>, <locale.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Stan- dard is the referee document. The original Standard can be obtained online at http://www.unix.org/online.html . Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . IEEE
/The Open Group 2013 LOCALECONV(3P)
All times are GMT -4. The time now is 04:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy