Sponsored Content
Top Forums Shell Programming and Scripting Replace string with lines stored in a file Post 303002318 by kraljic on Tuesday 22nd of August 2017 08:04:32 AM
Old 08-22-2017
Replace string with lines stored in a file

OS version: RHEL 6.7
Shell : Bash


I have a file like below

Code:
$ cat pattern.txt
'T_PKT_HEADER'
'T_ORD_ITM_LOYX'
'T_ORDERITM_TRMS'
'T_ORDER_ITEM'
'T_ORDER_ITM_PRI'
'T_ORDER_ITEM_OM'
'T_ORDER_ITEM_XA'
'T_ORDER_ATT'
'T_ORDER_ACTNSET'
'T_ORDER_XM'
'T_ORDER_X'
'T_ORDER_TNTX'
'T_ORDER_POSTN'
'T_ORDER_DTL'
'T_ORDER'
'T_ORDER_BU'
.
.

For the below command I want to replace <tableName in Single Quotes> with each line from the above file.
Is there any way I could do this ? Expected output shown below

exec dbms_stats.gather_table_stats(ownname => 'SIEBEL', tabname => <tableName in Single Quotes> ,degree => 3, cascade => true );

Expected output:

Code:
exec dbms_stats.gather_table_stats(ownname => 'SIEBEL', tabname => 'T_PKT_HEADER' ,degree => 3, cascade => true );
exec dbms_stats.gather_table_stats(ownname => 'SIEBEL', tabname => 'T_ORD_ITM_LOYX' ,degree => 3, cascade => true );
exec dbms_stats.gather_table_stats(ownname => 'SIEBEL', tabname => 'T_ORDERITM_TRMS' ,degree => 3, cascade => true );
.
.
.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

2. Shell Programming and Scripting

replace a string with contents of a txt file containing multiple lines of strings

Hello everyone, ive been trying to replace a string "kw01" in an xml file with the contents of a txt file having multiple lines. im a unix newbie and all the sed combinations i tried resulted to being garbled. Below is the contents of the txt file: RAISEDATTIME --------------------... (13 Replies)
Discussion started by: 4dirk1
13 Replies

3. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

4. Shell Programming and Scripting

Searching a string stored in other file

I need to design a script which can do the following: I have two files abc.txt and constant.hmtl abc.txt contains some 5 string that I need to see if they exist in contants.html. Constants.hmtl is a very large file around 800 lines. I want to search all the strings present in file... (8 Replies)
Discussion started by: hemasid
8 Replies

5. Shell Programming and Scripting

Search a string and replace the same string above two lines?.

I need to search this "<CardinalMPI>" string and replace the same string above two lines of the string. Nov 16, 2012 12:58:34 PM INFO: Centinel LookUp ResponseXML : <CardinalMPI> <ReasonCode></ReasonCode> <ErrorDesc></ErrorDesc> <MerchantReferenceNumber></MerchantReferenceNumber>... (4 Replies)
Discussion started by: laknar
4 Replies

6. Shell Programming and Scripting

Want to Insert few lines which are stored in some file before a pattern in another file

Hello, I have few lines to be inserted in file_lines_to_insert. In another file final_file, I have to add lines from above file file_lines_to_insert before a particular pattern. e.g. $ cat file_lines_to_insert => contents are abc def lkj In another file final_file, before a... (6 Replies)
Discussion started by: nehashine
6 Replies

7. Shell Programming and Scripting

Grep and sed (replace string in patterned lines)

Grep and Sed (replace string in patterned lines) Hi all, I want to grep for "PATTERN" and only if "PATTERN" is in a line, this line shall be used as replacement input e.g. for SED. I don't get it running in one line. NOT RUNNING - just first idea... I don't know how to redirect grep... (2 Replies)
Discussion started by: unknown7
2 Replies

8. Shell Programming and Scripting

Removing md5sum lines stored in text file

Hello. I'm writing a script where every file you create will generate a md5sum and store it into a text file. Say I create 2 files, it'll look like this in the text file: d41d8cd98f00b204e9800998ecf8427e /helloworld/saystheman d41d8cd98f00b204e9800998ecf8427e /helloworld/test I... (3 Replies)
Discussion started by: batarangs_
3 Replies

9. Shell Programming and Scripting

Replace a string with multiple lines

Hello Guys, I need to replace a string with multiple lines. For eg:- ABC,DEF,GHI,JKL,MNO,PQR,STU need to convert the above as below:- ABC,DEF, GHI1 GHI2 GHI3, JKL,MNO, PQR1 PQR2 PQR3, STU i have tried using code as:- (2 Replies)
Discussion started by: jassi10781
2 Replies

10. Shell Programming and Scripting

Replace a string on specific lines which match a pattren

Hi Experts, I have a file which contains a pattern multiple times i.e. matchthispattren. If a line is matched with this pattern. I want a number in 1234567890 to 123456789 in that line. (Basically remove the last digit from that number. Please help. Thanks, Varun (1 Reply)
Discussion started by: varun22486
1 Replies
XtAddGrab(3Xt)															    XtAddGrab(3Xt)

NAME
XtAddGrab, XtRemoveGrab - redirect user input to a modal widget SYNOPSIS
void XtAddGrab(w, exclusive, spring_loaded) Widget w; Boolean exclusive; Boolean spring_loaded; void XtRemoveGrab(w) Widget w; ARGUMENTS
Specifies whether user events should be dispatched exclusively to this widget or also to previous widgets in the cascade. Specifies whether this widget was popped up because the user pressed a pointer button. Specifies the widget to add to or remove from the modal cas- cade. DESCRIPTION
The XtAddGrab function appends the widget (and associated parameters) to the modal cascade and checks that exclusive is True if spring_loaded is True. If these are not True, XtAddGrab generates an error. The modal cascade is used by XtDispatchEvent when it tries to dispatch a user event. When at least one modal widget is in the widget cas- cade, XtDispatchEvent first determines if the event should be delivered. It starts at the most recent cascade entry and follows the cascade up to and including the most recent cascade entry added with the exclusive parameter True. This subset of the modal cascade along with all descendants of these widgets comprise the active subset. User events that occur outside the widgets in this subset are ignored or remapped. Modal menus with submenus generally add a submenu widget to the cascade with exclusive False. Modal dialog boxes that need to restrict user input to the most deeply nested dialog box add a subdialog widget to the cascade with exclusive True. User events that occur within the active subset are delivered to the appropriate widget, which is usually a child or fur- ther descendant of the modal widget. Regardless of where on the screen they occur, remap events are always delivered to the most recent widget in the active subset of the cas- cade that has spring_loaded True, if any such widget exists. The XtRemoveGrab function removes widgets from the modal cascade starting at the most recent widget up to and including the specified wid- get. It issues an error if the specified widget is not on the modal cascade. SEE ALSO
X Toolkit Intrinsics -- C Language Interface Xlib -- C Language X Interface XtAddGrab(3Xt)
All times are GMT -4. The time now is 05:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy