Remove line based on string and put new line with parameter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove line based on string and put new line with parameter
# 1  
Old 05-25-2011
Bug Remove line based on string and put new line with parameter

Hi Folks,

I am new to ksh, i have informatica parameter file that i need to update everyday with shell script. i need your help updating this file with new parameters.

sample data
[GLOBAL]

[s_m_STG_TABLE1]
$$TABLE1_DATE=04-27-2011

[s_m_STG_TABLE2]
$$TABLE2_DATE=04-23-2011

[s_m_STG_TABLE3]
$$TABLE3_DATE=03-19-2011

.......Highligned are the values i need to update everyday..with another parameter coming from sqlplus statement. This values are dynamic and random because i wont load every table everyday. I need to update Highlithed value with parameter.
# 2  
Old 05-25-2011
Try:
Code:
perl -i -pe 's/(?<=TABLE._DATE=).*/your_parameter/' file

Make a backup of your file first Smilie
This User Gave Thanks to bartus11 For This Post:
# 3  
Old 05-25-2011
MySQL Thanks...

i dont perl utility to my profile..is there anyway.this can be done using sed and awk
# 4  
Old 05-25-2011
Do you have GNU version of sed?
Code:
sed -i 's/\(TABLE._DATE=\).*/\1your_parameter/' file

This User Gave Thanks to bartus11 For This Post:
# 5  
Old 05-26-2011
Java Thanks Dude..

It solved my problem...

[---------- Post updated 05-26-11 at 07:49 AM ---------- Previous update was 05-25-11 at 03:50 PM ----------

it worked with double quotes
Code:
sed -i "s/\(TABLE._DATE=\).*/\1$parameter/" file

Moderator's Comments:
Mod Comment Thanks for the feedback, but please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks.

Last edited by zaxxon; 05-26-2011 at 11:51 AM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove line based on condition in awk

In the following tab-delimited input, I am checking $7 for the keyword intronic. If that keyword is found then $2 is split by the . in each line and if the string after the digits or the +/- is >10, then that line is deleted. This will always be the case for intronic. If $7 is exonic then nothing... (10 Replies)
Discussion started by: cmccabe
10 Replies

2. Shell Programming and Scripting

Remove sections based on duplicate first line

Hi, I have a file with many sections in it. Each section is separated by a blank line. The first line of each section would determine if the section is duplicate or not. if the section is duplicate then remove the entire section from the file. below is the example of input and output.... (5 Replies)
Discussion started by: ahmedwaseem2000
5 Replies

3. Shell Programming and Scripting

How to remove a line based on contents of the first column?

Good day all. Using basic UNIX/Linux tools, how would you delete a line based on a character found in column 1? For example, if the CITY name contains an 'a' or 'A', delete the line: New York City; New York Los Angeles; California Chicago; Illinois Houston; Texas Philadelphia;... (3 Replies)
Discussion started by: BRH
3 Replies

4. Shell Programming and Scripting

Replace line in file with line in another file based on matching string

HI Can any one guide me how to achieve this task. I have 2 files env.txt #Configuration.Properties values identity_server_url = http://identity.test-hit.com:9783/identity/service/user/register randon_password_length = 6 attachment_file_path = /pass/temp/attachments/... (1 Reply)
Discussion started by: nikilbr86
1 Replies

5. Shell Programming and Scripting

Replace and add line in file with line in another file based on matching string

Hi, I want to achieve something similar to what described in another post: The difference is I want to add the line if the pattern is not found. File 1: A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB ... (11 Replies)
Discussion started by: jyu3
11 Replies

6. Shell Programming and Scripting

Replace line in file with line in another file based on matching string

Hi I am not the best scripter in the world and have run into a issue which you might be able to guide me on... I have two files. File1 : A123, valueA, valueB B234, valueA, valueB C345, valueA, valueB D456, valueA, valueB E567, valueA, valueB F678, valueA, valueB File2: C345,... (5 Replies)
Discussion started by: luckycharm
5 Replies

7. Shell Programming and Scripting

How to use sed to put string end of line?

I have several file as below, and i want to put .txt to specific text contain ^main=EXE^cmd=run script /usr/prog/bd_, file1 7.9102 12.1528 16.3672 7.4002 ^main=EXE^cmd=run script /usr/prog/bd_123^" line 16.3672 7.3134 17.8711 6.0981 file 2 7.9102 12.1528 16.3672 7.4002 ... (8 Replies)
Discussion started by: zulabc
8 Replies

8. Shell Programming and Scripting

put string end of the line

I've a problem to put .h end of the line..below my input file fg_a bb fg_b bb fg_c bb fg_d aa fg_f ee and i want the output file as below fg_a.h bb fg_b.h bb fg_c.h bb fg_d.h (6 Replies)
Discussion started by: zulabc
6 Replies

9. Shell Programming and Scripting

replacing a string in a file with command line parameter

Hello, I am trying to replace a string with a paramter given along with the script. I am replacing application1 to application2 with the script: ./change_app.sh application2 change_app.sh: #!/bin/ksh grep $1 applications.dat 2>&1 >/dev/null echo $1 file=pckage.new sed 's/Name:... (5 Replies)
Discussion started by: chiru_h
5 Replies
Login or Register to Ask a Question