![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sed and whitespace characters | SAMZ | UNIX for Advanced & Expert Users | 1 | 07-03-2008 01:11 PM |
| Split a file with no pattern -- Split, Csplit, Awk | madhunk | UNIX for Dummies Questions & Answers | 10 | 12-17-2007 12:57 PM |
| Delete whitespace | truck7758 | Shell Programming and Scripting | 12 | 12-05-2007 12:00 PM |
| sed : remove whitespace | b.hamilton | Shell Programming and Scripting | 3 | 11-06-2007 11:02 AM |
| trim whitespace? | msteudel | Shell Programming and Scripting | 4 | 07-07-2005 08:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
split whitespace help
I have a file that I am spliting and parsing, if data starts with an N/n toos it (which works) but I want it to also see if the data is blank and toss it. What I have does not toss the blank space for dduck???? here is the data file and code I have..... efudd 7546 bbunny N0542 tdevil 6666 dduck mmouse 8888 Code:
open OUTER_HANDLE,"userids" or die "$!:$?";
while (<OUTER_HANDLE>) {
my @userData = split;
# print "DEBUG: Start... Number is [ $userData[1] ]\n";
if ( ! ($userData[1] =~ /[n|N]/)
or ! ($userData[1] =~ /\s/) ) {
# print "DEBUG: userData[0] : [$userData[0]]\n";
# print "DEBUG: userData[1] : [$userData[1]]\n";
ripItOut( $userData[0], $userData[1] );
}
}
close OUTER_HANDLE;
The usernames and numbers get printed out later on in the script. bbunny gets ignored as expected, but dduck prints out. Thanks for any input. theninja Last edited by theninja; 07-14-2008 at 05:05 PM.. |
|
|||||
|
Can you use the following logic? Code:
> cat file99 efudd 7546 bbunny N0542 tdevil 6666 dduck mmouse 8888 > cat file99 | grep [0-9][0-9] | grep -v [nN][0-9][0-9] efudd 7546 tdevil 6666 mmouse 8888 |
|
||||
|
Thanks for the replies, I was able to get it to work with the following... Code:
open OUTER_HANDLE,"userids" or die "$!:$?";
while (<OUTER_HANDLE>) {
@userData = split;
$arraySize = @userData;
#print "DEBUG: Array size [$arraySize]\n";
if ( $arraySize == 2 ) {
# print "DEBUG: Start... Number is [$userData[1]]\n";
if ( ($userData[1] !~ /^N/) ) {
#print "DEBUG: userData[0] : [$userData[0]]\n";
#print "DEBUG: userData[1] : [$userData[1]]\n";
ripItOut( $userData[0], $userData[1] );
}
}
}
close OUTER_HANDLE;
|
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|