12-18-2012
Adding fields to file
Hi All,
I have a file(Pipe Delimited) where i need to add a blank field before the last field and a blank field after the last field. Please help. I have provided below the sample input records and desired output.
Code:
Sample Input: A0010000|Abilene TX A 1|A0010957|Dallas TX|A0010998|West|US HEADQUARTERS A0010001|Akron OH A 1|A0010954|Cleveland OH|A0010997|Central|US HEADQUARTERS A0010002|Alaska AK A 1|A0010991|Seattle WA|A0010998|West|US HEADQUARTERS Sample Output Required: A0010000|Abilene TX A 1|A0010957|Dallas TX|A0010998|West||US HEADQUARTERS| A0010001|Akron OH A 1|A0010954|Cleveland OH|A0010997|Central||US HEADQUARTERS| A0010002|Alaska AK A 1|A0010991|Seattle WA|A0010998|West||US HEADQUARTERS|
Last edited by Scott; 12-18-2012 at 06:37 AM..
Reason: Double post. Closed.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Everybody,
I have an layout file like below
f1 1 char 10,
f2 11 char 2,
f3 13 char 1,
lineend 14 char 1
Their I need to add a new field which would be like
f5 char 3,
f6 char 2
The o/p should be
f1 1 char 10,
f2 11 char 2,
f3 13 char 1,
f5 14 char 3,
f6 17 char 2 (3 Replies)
Discussion started by: mr_manii
3 Replies
2. Shell Programming and Scripting
I have a file with 32 fields each separated by ‘|”. I need to add a file date exactly in the format “ "20100120" “ as the 32nd field moving the existing 32nd field to 33. so the field I added should be 32nd and the 33rd field is the last field before I added the file date.
I know we can... (8 Replies)
Discussion started by: dsravan
8 Replies
3. Shell Programming and Scripting
I need some help with adding lines to file and substitute a pattern.
Ok I have a file:
#cat names.txt
name: John Doe
stationed: 1
name: Michael Sweets
stationed: 41
.
.
.
And would like to change it to:
name: John Doe
employed
permanently
stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies
4. Programming
hi
i am student doing project in ns2.34.
i hav to add field in route cache and packet of DSR routing protocol.
which files hv to be changed...pl help me (1 Reply)
Discussion started by: khubalkar
1 Replies
5. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
want to add field to route cache and packet of DSR routing protocol in ns2.34, add field, DSR package in ns2.34... (2 Replies)
Discussion started by: khubalkar
2 Replies
6. Shell Programming and Scripting
Hi All,
I have a file(Pipe Delimited) where i need to add a blank field before the last field and a blank field after the last field. Please help. I have provided below the sample input records and desired output.
Sample Input:
A0010000|Abilene TX A 1|A0010957|Dallas TX|A0010998|West|US... (5 Replies)
Discussion started by: Arun Mishra
5 Replies
7. Shell Programming and Scripting
Hi All,
I get a file on weekly basis from client. I need to write a script which make sure the file should have 20 columns after the first column. If not then the script should add the remaining columns and default them to space(except for 2nd and 3rd). and at the same time the script should... (25 Replies)
Discussion started by: Arun Mishra
25 Replies
8. Shell Programming and Scripting
Dear AWK-experts!
I did get stuck in the task of combining files after matching fields, so I'm still awkward with learning AWK.
There are 2 files: one containing 3 columns with ID, coding status, and score for long noncoding RNAs:
file1 (1.txt) (>5000 lines)
... (12 Replies)
Discussion started by: kben
12 Replies
9. Shell Programming and Scripting
I have a file with 4 columns
a|b|c|d
I need to add single quotes around field 2 and 3
I need it to be like
a|'b'|'c'|d (5 Replies)
Discussion started by: dsravanam
5 Replies
10. UNIX for Beginners Questions & Answers
I have an array in an external file, "array.txt", which contains:
char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies
LEARN ABOUT DEBIAN
gd_bof
gd_bof(3) GETDATA gd_bof(3)
NAME
gd_bof -- report the start of data in a field
SYNOPSIS
#include <getdata.h>
off_t gd_bof(DIRFILE *dirfile, const char *field_code);
DESCRIPTION
The gd_bof() function queries a dirfile(5) database specified by dirfile and returns the sample number of the beginning-of-field marker for
the vector field given by field_code.
The caller should not assume that the beginning-of-field marker falls on a frame boundary. The beginning-of-field marker is never nega-
tive.
For a RAW field, the beginning-of-field corresponds to the frame offset of that field (see gd_frameoffset(3)). The beginning-of-field for
all other vector field type is the same as the beginning-of-field of whichever of its input fields that starts latest. The beginning-of-
field marker for the special field INDEX is always zero.
The beginning-of-field marker for a field containing no data is in the same location as, or after, its end-of-field marker (see gd_eof(3)).
For a RAW field, the difference between the locations of the beginning- and end-of-field markers indicates the number of samples of data
actually stored on disk.
The dirfile argument must point to a valid DIRFILE object previously created by a call to gd_open(3).
RETURN VALUE
Upon successful completion, gd_bof() returns the sample number of the end-of-field marker for the indicated field. On error, it returns -1
and sets the dirfile error to a non-zero error value. Possible error values are:
GD_E_BAD_CODE
The field specified by field_code or one of the fields it uses as input was not found in the database.
GD_E_BAD_DIRFILE
The supplied dirfile was invalid.
GD_E_BAD_REPR
The representation suffix specified in field_code, or in one of its inputs was not recognised.
GD_E_DIMENSION
A scalar field was found where a vector field was expected in the definition of field_code or one of its inputs, or else field_code
itself specified a scalar field.
GD_E_RECURSE_LEVEL
Too many levels of recursion were encountered while trying to resolve field_code. This usually indicates a circular dependency in
field specification in the dirfile.
The dirfile error may be retrieved by calling gd_error(3). A descriptive error string for the last error encountered can be obtained from
a call to gd_error_string(3).
SEE ALSO
dirfile(5), dirfile-encoding(5), gd_open(3), gd_eof(3), gd_error(3), gd_error_string(3), gd_nframes(3)
Version 0.7.0 15 October 2010 gd_bof(3)