![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To cut entire column from a file and apend it to another file as another column | sakthifire | Shell Programming and Scripting | 4 | 06-25-2008 01:27 AM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 06:57 AM |
| delete blank lines from a file | sachin.gangadha | UNIX for Dummies Questions & Answers | 2 | 12-04-2007 04:13 PM |
| Adding blank white sapce at specific column | Jae | Shell Programming and Scripting | 6 | 08-08-2007 05:20 AM |
| Blank Lines - End of file | saabir | Shell Programming and Scripting | 4 | 07-15-2003 08:55 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
Thanks a lot sir.
It worked. |
|
#4
|
|||
|
|||
|
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
|
||||
|
||||
|
hi, where are the pipes?
|
|
#6
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
||||
| Google The UNIX and Linux Forums |