Sponsored Content
Top Forums Shell Programming and Scripting To replace the value of the column in a fixed width file Post 302839589 by ginrkf on Friday 2nd of August 2013 06:03:20 AM
Old 08-02-2013
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 and 6 spaces in trailer to match with detail record length

current value of my header is
Column Name Data length
---------- ----------
Code:
A        1
B        2
C        2
D        8
E        8

current value of my trailer is

Column Name Data length
---------- ----------
Code:
A        1
B        2
C        15

My requirement is to change the value of the second column(Column B) from xx to yyy both in header and trailer.
After this change I should have only two spaces in header and 5 spaces in trailer

Can some one help here please

---------- Post updated at 05:03 AM ---------- Previous update was at 02:43 AM ----------

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 and 6 spaces in trailer to match with detail record length

current value of my header is

Code:
Column Name  Data length
----------   ----------
A        1
B        2
C        2
D        8
E        8

current value of my trailer is

Code:
Column Name  Data length
----------   ----------
A        1
B        2
C        15

My requirement is to change the value of the second column(Column B) from xx to yyy both in header and trailer.
After this change I should have only two spaces in header and 5 spaces in trailer

Last edited by Franklin52; 08-02-2013 at 04:48 AM.. Reason: Please use code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing column of variable length anf fixed width file

Hi, I have two input files. File1: ID Name Place 1-234~name1~Newyork 1-34~name2~Boston 1-2345~name3~Hungary File1 is a variable length file where each column is seperated by delimitter "~". File2: ID Country 1-34<<11 SPACES>>USA<<7 spaces>> 1-234<<10 SPACES>>UK<<8... (5 Replies)
Discussion started by: manneni prakash
5 Replies

2. 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

3. 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

4. UNIX for Dummies Questions & Answers

Remove duplicates based on a column in fixed width file

Hi, How to output the duplicate record to another file. We say the record is duplicate based on a column whose position is from 2 and its length is 11 characters. The file is a fixed width file. ex of Record: DTYU12333567opert tjhi kkklTRG9012 The data in bold is the key on which... (1 Reply)
Discussion started by: Qwerty123
1 Replies

5. 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

6. UNIX for Dummies Questions & Answers

Replace the unexpected newline char with space in a Fixed width file

Input eg: Ouput Expected. The #rd line had the unexpted new line, which need to be replaced with space. I was planing to go with checking the length of each line using awk and if the length is less than the defeined limit, (12 in above case) will replace the newline with space. ... (5 Replies)
Discussion started by: deepakwins
5 Replies

7. Shell Programming and Scripting

Print column details from fixed width file using awk command

hi, i have a fixed width file with multiple columns and need to print data using awk command. i use: awk -F "|" '($5 == BH) {print $1,$2,$3}' <non_AIM target>.txt for a delimiter file. but now i have a fixed width file like below: 7518 8269511BH 20141224951050N8262 11148 8269511BH... (5 Replies)
Discussion started by: kcdg859
5 Replies

8. Shell Programming and Scripting

Replace using awk on fixed width file.

All, I used to use following command to replace specific location in a fixed width file. Recently looks like my command stopped working as intended. We are on AIX unix. awk 'function repl(s,f,t,v) { return substr(s,1,f-1) sprintf("%-*s", t-f+1, v) substr(s,t+1) } NR<=10 {... (3 Replies)
Discussion started by: pinnacle
3 Replies

9. Shell Programming and Scripting

Search and replace value based on certain conditions in a fixed width file

Hi Forum. I tried searching for a solution using the internet search but I haven't been able to find any solution for what I'm trying to accomplish. I have a fixed width column file where I need to search for any occurrences of "D0" in col pos.#1-2, 10-11, 20-21 and replaced it with "XD". ... (2 Replies)
Discussion started by: pchang
2 Replies
AR(5)							      BSD File Formats Manual							     AR(5)

NAME
ar -- archive (library) file format SYNOPSIS
#include <ar.h> DESCRIPTION
The archive command ar combines several files into one. Archives are mainly used as libraries of object files intended to be loaded using the link-editor ld(1). A file created with ar begins with the ``magic'' string "!<arch> ". The rest of the archive is made up of objects, each of which is com- posed of a header for a file, a possible file name, and the file contents. The header is portable between machine architectures, and, if the file contents are printable, the archive is itself printable. The header is made up of six variable length ASCII fields, followed by a two character trailer. The fields are the object name (16 charac- ters), the file last modification time (12 characters), the user and group id's (each 6 characters), the file mode (8 characters) and the file size (10 characters). All numeric fields are in decimal, except for the file mode which is in octal. The modification time is the file st_mtime field, i.e., CUT seconds since the epoch. The user and group id's are the file st_uid and st_gid fields. The file mode is the file st_mode field. The file size is the file st_size field. The two-byte trailer is the string "` ". Only the name field has any provision for overflow. If any file name is more than 16 characters in length or contains an embedded space, the string "#1/" followed by the ASCII length of the name is written in the name field. The file size (stored in the archive header) is incre- mented by the length of the name. The name is then written immediately following the archive header. Any unused characters in any of these fields are written as space characters. If any fields are their particular maximum number of charac- ters in length, there will be no separation between the fields. Objects in the archive are always an even number of bytes long; files which are an odd number of bytes long are padded with a newline (`` '') character, although the size in the header does not reflect this. SEE ALSO
ar(1), stat(2) HISTORY
There have been at least four ar formats. The first was denoted by the leading ``magic'' number 0177555 (stored as type int). These ar- chives were almost certainly created on a 16-bit machine, and contain headers made up of five fields. The fields are the object name (8 characters), the file last modification time (type long), the user id (type char), the file mode (type char) and the file size (type unsigned int). Files were padded to an even number of bytes. The second was denoted by the leading ``magic'' number 0177545 (stored as type int). These archives may have been created on either 16 or 32-bit machines, and contain headers made up of six fields. The fields are the object name (14 characters), the file last modification time (type long), the user and group id's (each type char), the file mode (type int) and the file size (type long). Files were padded to an even number of bytes. For more information on converting from this format see arcv(8). The current archive format (without support for long character names and names with embedded spaces) was introduced in 4.0BSD. The headers were the same as the current format, with the exception that names longer than 16 characters were truncated, and names with embedded spaces (and often trailing spaces) were not supported. It has been extended for these reasons, as described above. This format first appeared in 4.4BSD. COMPATIBILITY
No archive format is currently specified by any standard. AT&T System V UNIX has historically distributed archives in a different format from all of the above. BSD
June 9, 1993 BSD
All times are GMT -4. The time now is 09:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy