You can do a loop, and use $ to turn a field number into field contents:
...but I suspect you're overthinking this a touch -- why bother using fields at all? Do a search/replace on the line itself and you'll get it all done in one gsub:
---------- Post updated at 10:04 AM ---------- Previous update was at 10:01 AM ----------
Okay, that doesn't work because gsub refuses to overlap like that. But my first example still works when you set FS and OFS properly.
The regex might as well be /^ $/ for that case, to prevent it eating spaces in the middle of a string.
hello.
I'm somewhat a novice here so please be patient. My stumbling block when loading csvs into ORACLE tables is this:
I need to read a csv datafile, check several fields in each line, and if any of stated fields contain A ZERO only then replace it with a null/blank character.
I had a... (9 Replies)
Hi
I use the following code to replace ‘.' with ‘N' in my files and keep both versions.
awk '{ gsub(/\./,"N"); print }' file_0001.txt > path/to/new/dir/file_0001.txt
I need help on how to apply the code to 100 files instead of doing them one file at a time. The files are labeled... (7 Replies)
I need to print the second field of a file, taking spaces, tab and = as field separators.
; for 16-bit app support
MAPI=1
CMC=1
CMCDLLNAME32=mapi32.dll
CMCDLLNAME=mapi.dll
MAPIX=1
MAPIXVER=1.0.0.1
OLEMessaging=1
asf=MPEGVideo
asx=MPEGVideo
ivf=MPEGVideo
m3u=MPEGVideo (2 Replies)
I have a pipe delimited file with 27 fields. Each record has 26 fields. I need to search for the 25,26,27 fields and replace "," with nothing.
How can I acheive this. Sed is more preferred.
e.g
data row
o/p (5 Replies)
Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ?
The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories.
So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Hi,
I am trying to execute this line
awk -F ";" -v OFS=";" '{gsub(/\./,",",$6); print}' FILE
but for multiple fields $6 $7 $8
Do you have a suggstion?
Tried:
awk -F ";" -v OFS="";"" "function GSUB( F ) {gsub(/\./,\",\",$F); print} { GSUB( 6 ); GSUB( 7 ); GSUB( 8 ) } 1"... (2 Replies)
Hello, I have the following input file:
1 3 3 2
3 3 4 0
4 0 5 4
5 2 2 0
5 3 4 0
6 0 3 2
I am trying to remove all zeroes in fields 2 and 4 and replace them with "1's"
I tried the following, but it's not working
awk -F"\t" '{ if (($2==0) || ($4==0) $2=1; $4=1; print $0 ) }' input
... (8 Replies)
so its common knowledge one can print multiple fields with simple commands like this:
echo 12 44 45 552 24 | awk '{print $1,$4,$3}'
but suppose i want to avoid specifying the "$" symbol. is that possible? can something like this be done:
echo 12 44 45 552 24 | awk '{print $(1,4,3)}'
... (9 Replies)
Discussion started by: SkySmart
9 Replies
LEARN ABOUT NETBSD
field_opts_off
FORMS(3) BSD Library Functions Manual FORMS(3)NAME
field_opts, field_opts_off, field_opts_on, set_field_opts -- form library
LIBRARY
Curses Form Library (libform, -lform)
SYNOPSIS
#include <form.h>
Form_Options
field_opts(FIELD *field);
int
field_opts_off(FIELD *field, Form_Options options);
int
field_opts_on(FIELD *field, Form_Options options);
int
set_field_opts(FIELD *field, Form_Options options);
DESCRIPTION
The function field_opts() returns the current options settings for the given field. The field_opts_off() will turn the options given in
options off for the given field, options not specified in options will remain unchanged. Conversely, the function field_opts_on() will turn
on the options given in options for the specified field, again, any options not specified will remain unchanged. The options for a field may
be set to a specific set of options by calling the set_field_opts() function. Options may only be changed if the field given is not the cur-
rently active one.
PARAMETERS
The following options are available for a field:
O_VISIBLE The field is visible, hence is displayed when the form is posted.
O_ACTIVE The field is active in the form, meaning that it can be visited during form processing.
O_PUBLIC The contents of the field are echoed to the screen.
O_EDIT The contents of the field can be modified
O_WRAP The contents of the field are wrapped on a word boundary, if this option is off then the field will be wrapped on a character
boundary.
O_BLANK Blank the field on new data being entered if and only if the field cursor is at the left hand side of the field.
O_AUTOSKIP Skip to the next field when the current field reaches its maximum size.
O_NULLOK The field is allowed to contain no data
O_STATIC The field is not dynamic, it has a fixed size.
O_PASSOK An unmodified field is allowed.
O_REFORMAT Retain the formatting of a field when the buffer is retrieved. If this option is not set then the buffer returned will be a sin-
gle string with no line breaks. When this option is set newline characters will be inserted at the point where the string has
been wrapped in a multiline field. This option is an extension to the forms library and must not be used in portable code. See
the field_buffer(3) man page for how this option modifies the behaviour of field_buffer().
The following options are on by default for a field: O_VISIBLE, O_ACTIVE, O_PUBLIC, O_EDIT, O_WRAP, O_BLANK, O_AUTOSKIP, O_NULLOK, O_PASSOK,
and O_STATIC.
RETURN VALUES
Functions returning pointers will return NULL if an error is detected. The functions that return an int will return one of the following
error values:
E_OK The function was successful.
E_CURRENT The field specified is the currently active one in the form.
SEE ALSO curses(3), forms(3)NOTES
The header <form.h> automatically includes both <curses.h> and <eti.h>. The option O_REFORMAT is a NetBSD
extension and must not be used in portable code.
BSD November 24, 2004 BSD