Sponsored Content
Top Forums Shell Programming and Scripting awk: How to check if field is blank? Post 74385 by yongho on Thursday 9th of June 2005 10:59:32 AM
Old 06-09-2005
Hmm

Each record (each line) contains 30 fields so I'll post the first two fields, that are relevant.

"test_val ","32 white spaces here"

That is $1, and $2.
I was trying to create a pattern that identifies that the first field contains the "test_val" and that the second field is empty/blank/full-of-whitespaces (anything that tells me it's empty). That second field, has 32 fixed-length whitespaces. It would otherwise normally be filled with a 7-digit number at the beginning.

Ah, the forum removed the 32 white spaces, but imagien that they are there.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to include field separator if there are blank fields?

Hi, I have the following data in the format as shown (note: there are more than 1 blank spaces between each field and the spaces are not uniform, meaning there can be one blank space between field1 and field2 and 3 spaces between field3 and field4, in this example, # are the spaces in between... (19 Replies)
Discussion started by: ReV
19 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

how to validate a field when it is blank using awk prog

Hi, I tried the below piece of code for my script to check whether it has a blank space for a particular field. if(f10==/]/){ print "Field 10 is Correct";} else{ print "Field 10 is Wrong"; } Please help me to know whether the "if" condition applied here is correct or do i... (14 Replies)
Discussion started by: meva
14 Replies

4. Shell Programming and Scripting

perl or awk, field length check

Hi Everyone, 1.txt a;1234;134;1111111 b;123;123;1111111 c;123;1334;1111111 d;1234;1234;1111111 output a;1234;134;1111111 c;123;1334;1111111 d;1234;1234;1111111 if field2 legth>3 or field3 length >3, then output. Please advice. Thanks (4 Replies)
Discussion started by: jimmy_y
4 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

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
form_field_opts(3X)													       form_field_opts(3X)

NAME
form_field_opts - set and get field options SYNOPSIS
#include <form.h> int set_field_opts(FIELD *field, Field_Options opts); int field_opts_on(FIELD *field, Field_Options opts); int field_opts_off(FIELD *field, Field_Options opts); Field_Options field_opts(const FIELD *field); DESCRIPTION
The function set_field_opts sets all the given field's option bits (field option bits may be logically-OR'ed together). The function field_opts_on turns on the given option bits, and leaves others alone. The function field_opts_off turns off the given option bits, and leaves others alone. The function field_opts returns the field's current option bits. The following options are defined (all are on by default): O_VISIBLE The field is displayed. If this option is off, display of the field is suppressed. O_ACTIVE The field is visited during processing. If this option is off, the field will not be reachable by navigation keys. Please notice that an invisible field appears to be inactive also. O_PUBLIC The field contents are displayed as data is entered. O_EDIT The field can be edited. O_WRAP Words that do not fit on a line are wrapped to the next line. Words are blank-separated. O_BLANK The field is cleared whenever a character is entered at the first position. O_AUTOSKIP Skip to the next field when this one fills. O_NULLOK Allow a blank field. O_STATIC Field buffers are fixed to field's original size. Turn this option off to create a dynamic field. O_PASSOK Validate field only if modified by user. RETURN VALUE
Except for field_opts, each routine returns one of the following: E_OK The routine succeeded. E_BAD_ARGUMENT Routine detected an incorrect or out-of-range argument. E_CURRENT The field is the current field. E_SYSTEM_ERROR System error occurred (see errno). SEE ALSO
curses(3X), form(3X). NOTES The header file <form.h> automatically includes the header file <curses.h>. PORTABILITY
These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions. AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. form_field_opts(3X)
All times are GMT -4. The time now is 01:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy