Visit Our UNIX and Linux User Community

search and replace fixed length record file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting search and replace fixed length record file
# 1  
Old 08-06-2009
search and replace fixed length record file


I need to be search a file of fixed length records and when I hit a particular record that match a search string, substitute a known position field

In the example file below

THEAD0000000002Y0000000012 P00000000000000001234
THEAD0000000004Y0000000044 N00000000000000001299

I need to only consider the THEAD records and swap the Ps to Ns, and visa versa, in position 40,

Thanks in advance

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Convert variable length record to fixed length

Hi Team, I have an issue to split the file which is having special chracter(German Char) using awk command. I have a different length records in a file. I am separating the files based on the length using awk command. The command is working fine if the record is not having any... (7 Replies)
Discussion started by: Anthuvan
7 Replies

3. Shell Programming and Scripting

Replace and Increment a value in the fixed length file

Hi Everyone, I need to increment a value in the fixed length file. The file has almost a million rows. Is there any easy way to accomplish this. Ex input file ASDSD ADSD 00000 X AAASD ADSD 00000 X SDDDD ADSD 00000 X Ouput ASDSD ADSD 00001 X AAASD ADSD 00002 X SDDDD ADSD 00003 X ... (7 Replies)
Discussion started by: saratha14
7 Replies

4. Shell Programming and Scripting

Replace Date in a fixed length file

Hello All, I working on ksh. I am using fixed length file. My file is like: ======== IXTTIV110827 NANTH AM IKSHIT ABCDEF 0617 IJAY NAND EENIG ZXYWVU 0912 AP OOK OONG PQRSTU100923 NASA DISH TTY ASDFG 0223 GHU UMA LAM QWERT 0111 ATHE SH THEW ======= From 7th to 12 is a date... (4 Replies)
Discussion started by: AnanthaDikshit
4 Replies

5. Shell Programming and Scripting

Add substring in a file containing fixed length record.

I am new to awk and writing a script using awk. I have file containing fixed length records, I wish to extract 2 substring(each substring is padded with zeros on left e.g 000000003623) and add each substring respectively for every record in the file to get total sum of respective substring for all... (5 Replies)
Discussion started by: Devesh5683
5 Replies

6. Shell Programming and Scripting

Search and replace particular characters in fixed length-file

Masters, I have fixed length input file like FHEAD0000000001XXXX20090901 0000009000Y1000XXX2 THEAD000000000220090901 ITM0000109393813 430143504352N22SP 000000000000RN000000010000EA P0000000000000014390020090901 TTAIL0000000003000000 FTAIL00000000040000000002 Note... (4 Replies)
Discussion started by: bittoo
4 Replies

7. Shell Programming and Scripting

Make variable length record a fixed length

Very, very new to unix scripting and have a unique situation. I have a file of records that contain 3 records types: (H)eader Records (D)etail Records (T)railer Records The Detail records are 82 bytes in length which is perfect. The Header and Trailer records sometimes are 82 bytes in... (3 Replies)
Discussion started by: jclanc8
3 Replies

8. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

9. Shell Programming and Scripting

sed replace with fixed length

$ cat template s.noName $ sed "s/" template > out $ sed "s/" template >>out $ cat out 1Name 100Name 1 Name 100Name (7 Replies)
Discussion started by: McLan
7 Replies

10. Shell Programming and Scripting

fixed record length

hello! I have a file with fixed record length... format: 123445asdfg 4343777 sfgg I wanna convert it to 123445,asdfg ,4343,777 ,sfgg is there any way to do it? sed/grep/awk?? at the moment I use sed -e 's_ \(\)_,\1_g' but it works only if there are spaces between... (16 Replies)
Discussion started by: george_
16 Replies

ausearch_add_interpreted_item - build up search rule SYNOPSIS
#include <auparse.h> int ausearch_add_interpreted_item(auparse_state_t *au, const char *field, const char *op, const char *value, ausearch_rule_t how); DESCRIPTION
ausearch_add_interpreted_item adds one search condition to the current audit search expression. The search conditions can then be used to scan logs, files, or buffers for something of interest. The field value is the field name that the value will be checked for. The op vari- able describes what kind of check is to be done. Legal op values are: exists just check that a field name exists = locate the field name and check that the value associated with it is equal to the value given in this rule. != locate the field name and check that the value associated with it is NOT equal to the value given in this rule. The value parameter is compared to the interpreted field value (the value that would be returned by auparse_interpret_field(3)). The how value determines how this search condition will affect the existing search expression if one is already defined. The possible val- ues are: AUSEARCH_RULE_CLEAR Clear the current search expression, if any, and use only this search condition. AUSEARCH_RULE_OR If a search expression E is already configured, replace it by (E || this_search_condition). AUSEARCH_RULE_AND If a search expression E is already configured, replace it by (E && this_search_condition). RETURN VALUE
Returns -1 if an error occurs; otherwise, 0 for success. SEE ALSO
ausearch_add_expression(3), ausearch_add_item(3), ausearch_add_timestamp_item(3), ausearch_add_regex(3), ausearch_set_stop(3), ause- arch_clear(3), ausearch_next_event(3), ausearch-expression(5). AUTHOR

Featured Tech Videos