Sponsored Content
Top Forums Shell Programming and Scripting how to validate a field when it is blank using awk prog Post 302354672 by ripat on Saturday 19th of September 2009 09:56:52 AM
Old 09-19-2009
Hi,

If you want to use regex the comparison operator i the tidle:
Code:
awk 'BEGIN{f10=" ";if(f10 ~ /^[[:space:]]$/) {print "Space"}else{print "not Space"}}'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk: How to check if field is blank?

In awk, I'd like to check if a field is blank. And by blank I mean, the field could be "" or " " In other words, the field could either be empty, or be filled with spaces. Would the regex look like this? $5 ~ // { Action }? What other ways are there? Hmm.. in any case I think... (7 Replies)
Discussion started by: yongho
7 Replies

2. Shell Programming and Scripting

fill a NIL into the blank field

Hello, I have a record which split with "," I would like to check..if the field is empty and it will field "NIL" into the field. input 45111,40404,peter,,0303403,0,030304,john,,9,0, output 45111,40404,peter,NIL,0303403,0,030304,john,NIL,9,0, (8 Replies)
Discussion started by: happyv
8 Replies

3. Shell Programming and Scripting

validate each field in txt

Hello, I have a file with a lot of record like below: 00001,CUSTR,CUSTOMER ADDRESS,02310,N,0:00,0,0,0,0,0,0,0,0,0,0,0,0:00,0,0,0,0,0,CSH,ACC Can I validate each record in the file and output the incorrect result? field 1 - customer number, should be "5 digit. field 2 - should be 5... (9 Replies)
Discussion started by: happyv
9 Replies

4. Shell Programming and Scripting

how to fix the column length in a file using Awk Prog

Hi I use the following code to read the file and to fix the length of the column of the record in the file 'Sample.txt' ls Samp* | awk ' { a=$1 } END{ FS="n" for(i=1;i<=NR;i++) { while( getline < a ) { f1=$0; print("Line::",f1); f2=substr(f1,1,10) print("Field1::",f2);... (10 Replies)
Discussion started by: meva
10 Replies

5. Shell Programming and Scripting

Find and replace blank in the last field

Hi all, I have a huge file and I need to get ride of the fields 6-11 and replace the blanks in field 5 with a missing value(99999). 159,93848,5354,343,67898,45,677,5443,434,5545,45 677,45545,3522,244, 554,54344,3342,456, 344,43443,2344,444,23477... (12 Replies)
Discussion started by: GoldenFire
12 Replies

6. Shell Programming and Scripting

Help with removal of blank spaces from the second field!

Hi everyone.. I'm trying to eliminate multiple whitespaces from a file.. I must make use of shell script to eliminate whitespaces.. Take a look at the sample file 1 int main() 2 { 3 int a,b; 4 printf("Enter the values of a and b"); 5 scanf("%d%d",&a,&b); 6 if(a>b) ... (6 Replies)
Discussion started by: abk07
6 Replies

7. Shell Programming and Scripting

awk - remove row if specific field is empty/blank

I have this text.filecharles darwin sam delight george washington johnson culper darwin sam delight micheal jackson penny lite and would like to remove the row, if the first field is blank. so the result would be: result.filecharles darwin sam ... (4 Replies)
Discussion started by: charles33
4 Replies

8. Shell Programming and Scripting

Adding an additional blank field to a file

Hi, I have the following file, I'd like to add an additional blank field to this file This is a tab delimited file, I have tried the same thing on excel, but looking for a unix solution. Here is my input: Country Postal Admin4 StreetBaseName StreetType HUN 2243 Kóka Dózsa György ... (3 Replies)
Discussion started by: ramky79
3 Replies

9. Shell Programming and Scripting

Find a blank field

Find a blank field Hi I have set of fields that have some blank values, how to find that and get its line noumbers in output file. Ex: Col1 col2 col3 11 ss 103 12 104 13 105 14 se 106 (2 Replies)
Discussion started by: Shenbaga.d
2 Replies

10. Shell Programming and Scripting

Find a blank field and replace values to NA

Hi All, i have a file like col1 col2 col3 13 24 NA 12 13 14 11 12 13 14 22 NA 18 26 NA in this file if i found "NA" other values in the line are also replace by NA Could you help me! (7 Replies)
Discussion started by: Shenbaga.d
7 Replies
Moose::Autobox(3)					User Contributed Perl Documentation					 Moose::Autobox(3)

NAME
Moose::Autobox - Autoboxed wrappers for Native Perl datatypes SYNOPOSIS
use Moose::Autobox; print 'Print squares from 1 to 10 : '; print [ 1 .. 10 ]->map(sub { $_ * $_ })->join(', '); DESCRIPTION
Moose::Autobox provides an implementation of SCALAR, ARRAY, HASH & CODE for use with autobox. It does this using a hierarchy of roles in a manner similar to what Perl 6 might do. This module, like Class::MOP and Moose, was inspired by my work on the Perl 6 Object Space, and the 'core types' implemented there. A quick word about autobox The autobox module provides the ability for calling 'methods' on normal Perl values like Scalars, Arrays, Hashes and Code references. This gives the illusion that Perl's types are first-class objects. However, this is only an illusion, albeit a very nice one. I created this module because autobox itself does not actually provide an implementation for the Perl types but instead only provides the 'hooks' for others to add implementation too. Is this for real? or just play? Several people are using this module in serious applications and it seems to be quite stable. The underlying technologies of autobox and Moose::Role are also considered stable. There is some performance hit, but as I am fond of saying, nothing in life is free. Note that this hit only applies to the use of methods on native Perl values, not the mere act of loading this module in your namespace. If you have any questions regarding this module, either email me, or stop by #moose on irc.perl.org and ask around. Adding additional methods Moose::Autobox asks autobox to use the Moose::Autobox::* namespace prefix so as to avoid stepping on the toes of other autobox modules. This means that if you want to add methods to a particular perl type (i.e. - monkeypatch), then you must do this: sub Moose::Autobox::SCALAR::bar { 42 } instead of this: sub SCALAR::bar { 42 } as you would with vanilla autobox. METHODS
mixin_additional_role ($type, $role) This will mixin an additonal $role into a certain $type. The types can be SCALAR, ARRAY, HASH or CODE. This can be used to add additional methods to the types, see the examples/units/ directory for some examples. TODO
More docs More tests BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. AUTHOR
Stevan Little <stevan@iinteractive.com> with contributions from: Anders (Debolaz) Nor Berle Matt (mst) Trout renormalist COPYRIGHT AND LICENSE
Copyright 2006-2008 by Infinity Interactive, Inc. <http://www.iinteractive.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-08-29 Moose::Autobox(3)
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy