Sponsored Content
Top Forums Shell Programming and Scripting Help in writing a find/replace script using awk Post 302359955 by Kocko on Wednesday 7th of October 2009 07:59:59 PM
Old 10-07-2009
Help in writing a find/replace script using awk

Hi All,

I need to write a script that will go through 600+ files and perform find and replace. I was going to use sed but there is a level of complexity that is doing my head in.

To explain: I have 600+ files that have a line in them that reads (for example)

FILE=DCLCLHST
REMARKS='CLAIM_HISTORY' $
SEGNAME=DCLCHST, SEGTYPE=SO
--Followed by anothe 50 lines or so---

In the line REMARKS='CLAIM_HISTORY' $ the $ is supposed to have a , in front so it reads REMARKS='CLAIM_HISTORY' ,$

I have played around with awk and came up with awk '/REMARKS/{if ($2=="$") $2=",$"; print > FILENAME}' *.mas

Of course the problem here is that the entire file gets over written and only the REMARKS line (correct mind you) exists within the file.

So I guess the question is how can I perform a find and replace on the $ only on the line that contains the word REMARKS without overwriting the rest of the file. Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

hi help in writing awk script(urgently)

hi to all i have file like this file.txt this is naryana expect hyderabad is a cool place now climate VISAKHSAPATNAM became very cool #vizag is my birth place #hyderabad is a cool place #now climate of hyd became very cool #vizag is my birth place #hyderabad is a cool place ... (7 Replies)
Discussion started by: LAKSHMI NARAYAN
7 Replies

2. Shell Programming and Scripting

plz help in writing awk script

hi buddies pls help in this matter i have file like this input file -------------------------- (PARTITION PARTITION_1 VALUES LESS THAN (101, 16383 ) TABLESPACE PART_1 ,PARTITION PARTITION_2 VALUES LESS THAN (101, 32766 ) TABLESPACE PART_2 ,PARTITION PARTITION_3 VALUES LESS THAN (101,... (3 Replies)
Discussion started by: LAKSHMI NARAYAN
3 Replies

3. UNIX for Dummies Questions & Answers

Help writing a script to find a file

I just started learning about Unix and I cant figure out what im doing wrong. I'm trying to write a script that will ask for the file name and tell what type it is. This is what i have so far. http://i63.photobucket.com/albums/h123/wacand/untitled.jpg (2 Replies)
Discussion started by: wacand
2 Replies

4. Shell Programming and Scripting

writing shell script to find line of invalid characters

Hi, I have to write s script to check an input file for invalid characters. In this script I have to find the exact line of the invalid character. If the input file contain 2 invalid character sat line 10 and 17, the script will show the value 10 and 17. Any help is appreciated. (3 Replies)
Discussion started by: beginner82
3 Replies

5. Shell Programming and Scripting

Need some help writing a find script

hello all! well, here is my problem: i have to write a script which waits for a directory as an argument and scans it recuresively and than it prints those files, which have write permission for everyone (as relative path from the argument directory so the find will be the key). and it shouldnt... (9 Replies)
Discussion started by: Mixe3y
9 Replies

6. UNIX for Dummies Questions & Answers

awk: issues for writing a script

%%%%% (7 Replies)
Discussion started by: lucasvs
7 Replies

7. Shell Programming and Scripting

help with writing a awk/sed script

Hi, I thought I am getting pretty good with sed and awk, but now I dont have a way out of this question. I have a table 0.5 16 1.3 14 0.25 15 0.85 16 I want to make a column 3 which contains values that are (corresponding $2 value/sum of all $2). Please help me out here. Thanks. (6 Replies)
Discussion started by: jamie_123
6 Replies

8. Shell Programming and Scripting

awk script to find data in three file and perform replace operation

Have three files. Any other approach with regards to file concatenation or splitting, etc is appreciated If column55(billngtype) of file1 contains YMNC or YPBC then pick the value of column13(documentnumber). Now find this documentnumber in column1(Billdoc) of file2 and grep the corresponding... (4 Replies)
Discussion started by: as7951
4 Replies

9. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies

10. Shell Programming and Scripting

Script using awk to find and replace a line, how to ignore comment lines

Hello, I have some code that works more or less. This is called by a make file to adjust some hard-coded definitions in the src code. The script generated some values by looking at some of the src files and then writes those values to specific locations in other files. The awk code is used to... (3 Replies)
Discussion started by: LMHmedchem
3 Replies
ldns(3) 						     Library Functions Manual							   ldns(3)

NAME
ldns_key_new_frm_fp_dsa, ldns_key_new_frm_fp_dsa_l SYNOPSIS
#include <stdint.h> #include <stdbool.h> #include <ldns/ldns.h> DSA* ldns_key_new_frm_fp_dsa(FILE *fp); DSA* ldns_key_new_frm_fp_dsa_l(FILE *fp, int *line_nr); DESCRIPTION
ldns_key_new_frm_fp_dsa() frm_fp helper function. This function parses the remainder of the (DSA) priv. key file fp: the file to parse Returns NULL on failure otherwise a RSA structure ldns_key_new_frm_fp_dsa_l() frm_fp helper function. This function parses the remainder of the (DSA) priv. key file fp: the file to parse line_nr: pointer to an integer containing the current line number (for debugging purposes) Returns NULL on failure otherwise a RSA structure AUTHOR
The ldns team at NLnet Labs. Which consists out of Jelte Jansen and Miek Gieben. REPORTING BUGS
Please report bugs to ldns-team@nlnetlabs.nl or in our bugzilla at http://www.nlnetlabs.nl/bugs/index.html COPYRIGHT
Copyright (c) 2004 - 2006 NLnet Labs. Licensed under the BSD License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
ldns_key_new_frm_fp, ldns_key. And perldoc Net::DNS, RFC1034, RFC1035, RFC4033, RFC4034 and RFC4035. REMARKS
This manpage was automaticly generated from the ldns source code by use of Doxygen and some perl. 30 May 2006 ldns(3)
All times are GMT -4. The time now is 05:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy