Sponsored Content
Top Forums Shell Programming and Scripting Parsing a fixed column text file in sed Post 302947919 by Scrutinizer on Tuesday 23rd of June 2015 11:23:50 PM
Old 06-24-2015
Quote:
Originally Posted by wvdeijk
[..]
Can anyone please give me an idea of how to do this. Thanks.
Is your input space delimited? You can loop over the fields starting on field 2 with increments of 2 and print the first field and the current field plus its right hand neighbor...

If it is fixed width you can call substring functions to specify the fields...

Last edited by Scrutinizer; 06-25-2015 at 07:59 PM.. Reason: with -> width
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

(sed) parsing insert statement column that crosses multiple lines

I have a file with a set of insert statements some of which have a single column value that crosses multiple lines causing the statement to fail in sql*plue. Can someone help me with a sed script to replace the new lines with chr(10)? here is an example: insert into mytable(id, field1, field2)... (3 Replies)
Discussion started by: jjordan
3 Replies

2. UNIX Desktop Questions & Answers

Help with Fixed width File Parsing

I am trying to parse a Fixed width file with data as below. I am trying to assign column values from each record to variables. When I parse the data, the spaces in all coumns are dropped. I would like to retain the spaces as part of the dat stored in the variables. Any help is appreciated. I... (4 Replies)
Discussion started by: sate911
4 Replies

3. Shell Programming and Scripting

print a file with one column having fixed character length

Hi guys, I have tried to find a solution for this problem but couln't. If anyone of you have an Idea do help me. INPUT_FILE with three columns shown to be separated by - sign A5BNK723NVI - 1 - 294 A7QZM0VIT - 251 - 537 A7NU3411V - 245 - 527 I want an output file in which First column... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

4. Shell Programming and Scripting

edit entire column from a fixed-width file using awk or sed

Col1 Col2 Col3 Col4 12 Completed 08 0830 12 In Progress 09 0829 11 For F U 07 0828 Considering the file above, how could i replace the third column the most efficient way? The actual file size is almost 1G. I am... (10 Replies)
Discussion started by: tamahomekarasu
10 Replies

5. Shell Programming and Scripting

Changing one column of delimited file column to fixed width column

Hi, Iam new to unix. I have one input file . Input file : ID1~Name1~Place1 ID2~Name2~Place2 ID3~Name3~Place3 I need output such that only first column should change to fixed width column of 15 characters of length. Output File: ID1<<12 spaces>>Name1~Place1 ID2<<12... (5 Replies)
Discussion started by: manneni prakash
5 Replies

6. Shell Programming and Scripting

Text file -> fixed column -> MySQL DB

Hi ! I have searched in the forum, but i'm not able to combine various solution to help me ! My problem is very simple for a bash scripter or a old linux man, but not for me (novice and inexperienced). I need to store in a mysql database the output of "last" command, but the table where i need... (2 Replies)
Discussion started by: axl936
2 Replies

7. Shell Programming and Scripting

How to split a fixed width text file into several ones based on a column value?

Hi, I have a fixed width text file without any header row. One of the columns contains a date in YYYYMMDD format. If the original file contains 3 dates, I want my shell script to split the file into 3 small files with data for each date. I am a newbie and need help doing this. (14 Replies)
Discussion started by: bhanja_trinanja
14 Replies

8. UNIX for Dummies Questions & Answers

Use sed to replace but only in a specific column of the text file

Hi, I would like to use sed to replace NA to x ('s/NA/x/g'), but only in the 5th column of the space delimited text file, nowhere else. How do I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

9. Shell Programming and Scripting

To replace the value of the column in a fixed width file

I have a fixed with file with header & trailer length having the same length of the detail record file. The details record length of this file is 24, for Header and Trailer the records will be padded with spaces to match the record length of the file Currently I am adding 3 spaces in header... (14 Replies)
Discussion started by: ginrkf
14 Replies

10. UNIX for Beginners Questions & Answers

Parsing a column of text file - best practices

HI Folks - I hope all is well! I have a business process where I manage a text file of substitution variables and their values for a target system. After updating, I run a script to push the changes to the target system. However, I'm trying to develop a method to be able to automatically... (50 Replies)
Discussion started by: SIMMS7400
50 Replies
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)
All times are GMT -4. The time now is 05:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy