The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to split pipe delimited file njgirl Shell Programming and Scripting 4 06-18-2008 06:15 PM
Help needed in removing intermediate segments from a pipe delimited segment file naren_0101bits Shell Programming and Scripting 3 12-03-2007 11:54 AM
splitting a pipe delimited file in unix ddedic Shell Programming and Scripting 4 03-20-2007 01:16 AM
Grep for NULL for a specific field in a unix file sureshg_sampat UNIX for Dummies Questions & Answers 5 11-24-2006 09:21 AM
Pipe Data From Grep Into A File katinicsdad Shell Programming and Scripting 4 09-08-2006 12:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-20-2006
sureshg_sampat sureshg_sampat is offline
Registered User
  
 

Join Date: Nov 2006
Location: Czech Republic
Posts: 49
Grep for NULL in a pipe delimited file

hi,

How can I check for a field in a pipe-delimited file having a NULL value in Unix using a grep command or any other command.

Please reply
  #2 (permalink)  
Old 11-20-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,423
What do you mean by NULL field ?
An empty field or a field equal to binary zero ?


Jean-Pierre.
  #3 (permalink)  
Old 11-21-2006
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
Quote:
Originally Posted by sureshg_sampat
hi,

How can I check for a field in a pipe-delimited file having a NULL value in Unix using a grep command or any other command.

Please reply
maybe this is what you want:
Code:
perl -n  -e 'print $_ if m#\|\|#' somefile
  #4 (permalink)  
Old 11-21-2006
cskumar cskumar is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 67
try this one

awk -F "|" '{for (i=0;i<=NF;i++){if(length($i) ==0) { val=$0 }} print val}' file1 > outputfile
  #5 (permalink)  
Old 11-21-2006
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
or this might be as simple as:
Code:
grep "||" somefile
  #6 (permalink)  
Old 11-21-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,423
A grep for || doesn't select null field at start or end of line.
Try :

Code:
egrep '^\||\|\||\|$' somefile
Note: The egrep command is the same as the grep -E command.

Jean-Pierre.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0