Blank column in a file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Blank column in a file.
# 1  
Old 12-28-2007
Blank column in a file.

hi,
Please tell me a way in which i can find out all the blank columns in the file which is pipe-delimited.after finding the blank column i want to find the line number.
# 2  
Old 12-28-2007
For ex:
Code:
> cat f3
231|212|212
231|212|212
|212|212
231|212|212
231|||212
231|212|212
231|212|

Code:
>awk '{
     for(i=0;i<=NF;i++)
        if ( $i == "" )
           print "line:"NR " column:"i
}' FS="|" f3
line:3 column:1
line:5 column:2
line:5 column:3
line:7 column:3

# 3  
Old 12-28-2007
Thanks a lot sir.
It worked.Smilie
# 4  
Old 12-28-2007
D 2382994 ACE 9724029474 9728690617 000 Dallas County Utility 0 ADSL STATIC 6000 N O'Connor Blvd
D 2685592 ACE 8584511009 8584518859 544 JAMES KENNEDY 12 ADSL STATIC 14755 Bud'S Ln
-

but as the last column is empty it is not finding this line.
Can u please tell me?
# 5  
Old 12-28-2007
hi, where are the pipes?
# 6  
Old 12-28-2007
Sorry.
last one is having - sign and all the other fields r blank.
so i should get the column no,. and line no.
D|2382994 ACE|9724029474|9728690617 000|Dallas County Utility|0|ADSL STATIC|6000|N O'Connor Blvd
D|2685592 ACE|8584511009|8584518859 544|JAMES KENNEDY|12|ADSL STATIC|14755|Bud'S Ln
-
# 7  
Old 12-28-2007
The third register has only one field and it is not empty, anyway if you want to fix the code to match it:

Code:
>awk '{
     for(i=0;i<=NF;i++)
        if ( $i == "" || $i == "-" )
           print "line:"NR " column:"i
}' FS="|" f3

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split file when value in column is blank

Hi Experts, In short : Need to split file when field in column 5 is blank and need to generate two file in which column 5 is blank and other in which column 5 has values along with other rows and column data My issue is i am not able to get header for column from raw file into new file which... (4 Replies)
Discussion started by: as7951
4 Replies

2. Shell Programming and Scripting

Split column when value in column is blank in any row

Hi Experts, In short : Need to split file when field in column 5 is blank and need to generate two file in which column 5 is blank and other in which column 5 has values along with other rows and column data My issue is i am not able to get header for column from raw file into new file which... (1 Reply)
Discussion started by: as7951
1 Replies

3. Shell Programming and Scripting

Column value can be Two integer post decimal or blank

Hi Experts, Need your advice. I have a csv file in which column value can contain two integer post decimal(like 1.00, 13.00,12.15, 2.43) or blank. Tried the below code but not working. awk -F "|" '{ if ($39 !~ /^+\.{2}$ || $39 != "") {print "165: Quantity decimal values are not correct... (2 Replies)
Discussion started by: as7951
2 Replies

4. Shell Programming and Scripting

To check Blank Lines, Blank Records and Junk Characters in a File

Hi All Need Help I have a file with the below format (ABC.TXT) : «┐┐ABCDHEJJSJJ|XCBJSKK01|M|7348974982790 HDFLJDKJSKJ|KJALKSD02|M|7378439274898 KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999 (cont......) I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Discussion started by: chatwithsaurav
6 Replies

5. UNIX for Advanced & Expert Users

Delete blank spaces and blank lines in a file

Hi Gurus, Somebody can say me how to delete blank spaces and blank lines in a file unix, please. Thank you for advanced. (10 Replies)
Discussion started by: systemoper
10 Replies

6. Shell Programming and Scripting

Insert data in first column(if blank) from previous line first column

Dear Team I need to insert field(which is need to taken from previous line's first field) in first column if its blank. I had tried using sed but not find the way. Detail input and output file as below. Kindly help for same. INPUT: SCGR SC DEV DEV1 NUMDEV DCP ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

7. Shell Programming and Scripting

Add a character C in a column if that column is blank

I have some files that look as follows. I need to add a character 'C' in the fifth column if that column is blank. I prefer in-place editing. 1 1 B M 0 0 203 0, 0.0 0, 0.0 0, 0.0 0, 0.0 0.000 360.0 360.0 360.0 141.9 15.4 28.8 66.1 2 2 B A ... (21 Replies)
Discussion started by: thejitha
21 Replies

8. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

9. Shell Programming and Scripting

Help me! grep the log file without blank lines in column

Hi, I have log file like this: i want grep the log file without blank lines in column 4. So the file is become like this : What is the command? please help me. (1 Reply)
Discussion started by: justbow
1 Replies

10. Shell Programming and Scripting

Adding blank white sapce at specific column

I have a file looking like this. But, if you look at second line, the number are stick together(e.g. 33.9918.913418.9570). What I want to do is to separate these number by white space. I tried to use tr below, but it doesn't work. Any help would be appreciated. <Input> 7.23 7.32 5.21 10.13 ... (6 Replies)
Discussion started by: Jae
6 Replies
Login or Register to Ask a Question