Sponsored Content
Top Forums Shell Programming and Scripting How to grep an empty line in a specific column of a file? Post 302753031 by Ravi Tej on Tuesday 8th of January 2013 01:49:12 AM
Old 01-08-2013
How to grep an empty line in a specific column of a file?

Suppose i have the following data :

cat file.txt

Code:
12431,123334,55353,546646,14342234,4646,35234
123123,3535,123434,132535,1234134,13535,123534
123213,545465,23434,45646,2342345,4656,31243
2355425,2134324,53425,342,35235,23434,234535
3423424,234234,65465,,2344,35436,234524,234
2345235,343224,234234,,234234,646,2342,2354
324234,6456,23424,,45645,234,234,246545,234
342334,234545,234,,2342,4354,2344,235235,2344

please suggest the below question :

1 . I want only those rows in which the fourth column is empty .

*********
it should generate the last four lines
*********

Last edited by Scrutinizer; 01-08-2013 at 03:14 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Retrieve line from a file based on a value in specific column

Hi, I have a file that has several values seperated by ":" 2006:John:Student:Football:Portugal:Cinema 2006:James:Engineer:Basket:Poland:Theatre 2007:Lucy:Diver:Gymnastic:England:Music 2007:Smith:Plumber:Basket:Spain:Poker I need make a filter based on the 5th field to find countries that... (1 Reply)
Discussion started by: efernandes
1 Replies

2. UNIX for Dummies Questions & Answers

(cont) Retrieve line from a file based on a value in specific column

HI, Your help was great: awk -F":" '$5 ~ /^P/{print }' file I would like to know what changes need to be done to this line code, so that I can put it in a shell script and call it as the example below. example: countries that start with chacater 'P' > country P Result: ... (0 Replies)
Discussion started by: efernandes
0 Replies

3. Shell Programming and Scripting

grep on specific line of the file

Hi, how can we search for a word (with case ignore )on specific line numbers ex: Awk /^regEX/ with condition on first line or second line Awk/^ regex1/ on line 1 Awk /^regEX2/ on line 3 thanks in advance (4 Replies)
Discussion started by: rider29
4 Replies

4. Shell Programming and Scripting

grep a specific line from a file

Is there a way to grep only one line from a file listing name of files? If I use head -1 it's ok(the first line only) If I use head -2 it's not good because I have already checked the first line. I'd like something like this: while test $i -le $max do grep "$3" `head -$i temp.txt` >... (4 Replies)
Discussion started by: Max89
4 Replies

5. Shell Programming and Scripting

delete empty spaces at specific column

Hi All, If anybody could help me with my scenario here. I have a statement file. Example of some content: DATE DESC Debit Credit Total Rate 02-Jan-08 Lodgement 200.00 1200.00 2.51 14-Sep-07 Withdrawal 50.00 1000.00 ... (8 Replies)
Discussion started by: yonez
8 Replies

6. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

7. UNIX for Dummies Questions & Answers

Grep from specific column in one file based on another file [Please help!]

Hey Guys, to keep it simple, I have an idFile: 1006006 1006008 1006011 1007002 ...... and famFile: 1006 1006001 1006016 1006017 1 1006 1006006 1006016 1006017 1 1006 1006007 0 0 2 1006 1006008 1006007 1006006 2 1006 1006010 1006016 1006017 2 1006 1006011 1006016 1006017 1 1006... (2 Replies)
Discussion started by: Zoho
2 Replies

8. Shell Programming and Scripting

How to read particular line in file from specific column?

Hi...friends.... I want to create inventory...information for that I need to read some specific row say 2nd row from 1st 3 column and and write data with particular file used, I have some more column also but I need only 3 column data of first entry after header I attached sample file..those... (12 Replies)
Discussion started by: nex_asp
12 Replies

9. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies
localeconv(3C)						   Standard C Library Functions 					    localeconv(3C)

NAME
localeconv - get numeric formatting information SYNOPSIS
#include <locale.h> struct lconv *localeconv(void); DESCRIPTION
The localeconv() function sets the components of an object with type struct lconv (defined in <locale.h>) with the values appropriate for the formatting of numeric quantities (monetary and otherwise) according to the rules of the current locale (see setlocale(3C)). The defini- tion of struct lconv is given below (the values for the fields in the "C" locale are given in comments). char *decimal_point; /* "." */ char *thousands_sep; /* "" (zero length string) */ 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_MAX */ char frac_digits; /* CHAR_MAX */ char p_cs_precedes; /* CHAR_MAX */ char p_sep_by_space; /* CHAR_MAX */ char n_cs_precedes; /* CHAR_MAX */ char n_sep_by_space; /* CHAR_MAX */ char p_sign_posn; /* CHAR_MAX*/ char n_sign_posn; /* CHAR_MAX */ The following members are also available to SUSv3-conforming applications. See standards(5) char int_p_cs_precedes; /* CHAR_MAX */ char int_p_sep_by_space; /* CHAR_MAX */ char int_n_cs_precedes; /* CHAR_MAX */ char int_n_sep_by_space; /* CHAR_MAX */ char int_p_sign_posn; /* CHAR_MAX */ char int_n_sign_posn; /* CHAR_MAX */ The members of the structure with type char * are 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 non-negative numbers, any of which can be CHAR_MAX (defined in the <limits.h> header) to indicate that the value is not available in the current locale. The members are the following: char *decimal_point The decimal-point character used to format non-monetary quantities. char *thousands_sep The character used to separate groups of digits to the left of 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: 1995 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 decimal point used to format monetary quantities. char *mon_thousands_sep The separator for groups of digits to the left of 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 to the right of the decimal point) to be displayed in an internationally formatted monetary quantity. char frac_digits The number of fractional digits (those to the right of the decimal point) to be displayed in a formatted monetary quantity. char p_cs_precedes Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a non-negative formatted monetary quantity. char p_sep_by_space Set to 0 if no space separates the currency_symbol or int_curr_symbol from the value for a non-negative formatted monetary quantity. Set to 1 if a space separates the symbol from the value; and set to 2 if a space separates the symbol and the sign string, if adjacent. char n_cs_precedes Set to 1 or 0 if the currency_symbol respectively precedes or succeeds the value for a negative formatted monetary quantity. char n_sep_by_space Set to 0 if no space separates the currency_symbol or int_curr_symbol from the value for a negative formatted monetary quantity. Set to 1 if a space separates the symbol from the value; and set to 2 if a space separates the symbol and the sign string, if adjacent. 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 monetary 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 for- matted 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 format- ted 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 cur- rency 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. In an SUSv3-conforming application, 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. RETURN VALUES
The localeconv() function returns a pointer to the filled-in object. The structure pointed to by the return value may be overwritten by a subsequent call to localeconv(). EXAMPLES
Example 1: Rules used by four countries to format monetary quantities. The following table illustrates the rules used by four countries to format monetary quantities. Country Positive Negative International Italy (IT) L.1.234 -L.1.234 ITL.1.234 Netherlands (NE) F 1.234,56 F -1.234,56 NLG 1.234,56 Norway (NO) kr1.234,56 kr1.234,56- NOK 1.234,56 Switzerland (SW) 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 as follows: IT NE NO SW int_curr_symbol "ITL." "NLG " "NOK " "CHF " currency_symbol "L." "F" "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 ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe with exceptions | +-----------------------------+-----------------------------+ The localeconv() function can be used safely in multithreaded applications, as long as setlocale(3C) is not being called to change the locale. SEE ALSO
setlocale(3C), attributes(5), environ(5), standards(5) SunOS 5.10 12 Dec 2003 localeconv(3C)
All times are GMT -4. The time now is 10:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy