Blank column in a file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Blank column in a file.
# 8  
Old 12-31-2007
thanks sir.
but what this is not searching for the file as
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
-||||||||

means all its columns are blank.And what if instead of - Its D there.
Please reply ASAP.
Thanks
# 9  
Old 12-31-2007
Sorry Mohit , i can't reproduce your issue . It works for me as u see:

Code:
> cat f1
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
-||||||||

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

another example:

Code:
> cat f1
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
-|||D|||O||

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

Regards

Last edited by Klashxx; 12-31-2007 at 05:02 AM.. Reason: extra characters deleted
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