Sponsored Content
Top Forums Shell Programming and Scripting search and replace with data from another file Post 302400178 by paruthiveeran on Tuesday 2nd of March 2010 11:45:53 AM
Old 03-02-2010
search and replace with data from another file

Can someone help me in solving the problem below.

I have the following two files

Code:
template_file
------------
...other data..
...other data..
FILE_NAME=
...other data..
...other data..

list_file
----------
<file_name1>
<file_name2>
<file_name3>

I need to produce another output file as

Code:
new_template_file
------------------
...other data..
FILE_NAME=/core/local/in/<file_name1> FILE_NAME=/core/local/in/<file_name2> FILE_NAME=/core/local/in/<file_name3>
...other data..
...other data..

Simply, I need to read the list file and prefix the path /core/local/in to the file names and then look for keyword FILE_NAME in the template and replace it with the file names that I received in list file.

Last edited by Scott; 03-02-2010 at 02:09 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search and replace dynamic data in a shell script

Hi, I have a file that looks something like this: ... 0,6,256,87,0,0,0,1187443420 0,6,438,37,0,0,0,1187443380 0,2,0,0,0,10,0,1197140320 0,3,0,0,0,10,0,1197140875 0,2,0,0,0,23,0,1197140332 0,3,0,0,0,23,0,1197140437 0,2,0,0,0,17,0,1197140447 0,3,0,0,0,17,0,1197140543... (8 Replies)
Discussion started by: csejl
8 Replies

2. UNIX for Dummies Questions & Answers

Search and replace in file

Hi guys, I have one file with duplicate string. I want to replace all the occurance of that string with some other string. How can I do that in vi editor? Malay Maru (3 Replies)
Discussion started by: malaymaru
3 Replies

3. UNIX for Advanced & Expert Users

search and replace in a file

I have a file (say file1.txt) and I have to search for a line which has a text replace it and replace another string too in the same line. Eg: file1.txt -------- x='hai' y='world' z='unix' x='hai' y='world' x='hai' z='perl' y='world' z="world" k="junk" b="world" z='perl' x='hai'... (3 Replies)
Discussion started by: ammu
3 Replies

4. Shell Programming and Scripting

Find and replace data in text file with data in same file

OK I will do my best to explain what I need help with. I am trying to format an ldif file so I can import it into Oracle oid. I need the file to look like this example. Keep in mind there are 3000 of these in the file. changetype: modify replace: userpassword dn:... (0 Replies)
Discussion started by: timothyha22
0 Replies

5. Shell Programming and Scripting

Replace data of one column with data on other file corresponding to transaction ID matched

Hi All, I have two files one of which having some mobile numbers and corresponding value whose sample content as follows: 9058629605,8.0 9122828964,30.0 And in second file complete details of all mobile numbers and sample content as follows and delimeter used is comma(,): ... (8 Replies)
Discussion started by: poweroflinux
8 Replies

6. Shell Programming and Scripting

Using sed to search and replace data

Hi, Kindly need your expertise in this problem. I have to search and replace data. The problem is, the data is in the same format but slightly different content. What I need is sed commands that can work for those "slightly different content". input: ... (3 Replies)
Discussion started by: Alvin123
3 Replies

7. Shell Programming and Scripting

awk/sed to search & replace data in first column

Hi All, I need help in manipulating the data in first column in a file. The sample data looks like below, Mon Jul 18 00:32:52 EDT 2011,NULL,UAT Jul 19 2011,NULL,UAT 1] All field in the file are separated by "," 2] File is having weekly data extracted from database 3] For eg.... (8 Replies)
Discussion started by: gr8_usk
8 Replies

8. Shell Programming and Scripting

Replace data of a file with data from another file using shell scripting.

Dears, I'm new to shell scripting and i was wondering if you can help me with following matter. I have a file containing 400,000 records. The file contains two columns like: 00611291,0270404000005453 25262597,1580401000016155 25779812,1700403000001786 00388934,1200408000000880... (1 Reply)
Discussion started by: paniklas
1 Replies

9. Shell Programming and Scripting

Search and replace data

FILENAME: (Orig File) lab computer11node1 { hardware ok 19:50:56:bd:03:c2; MAC-ADDRESS 10.1.1.1; } lab computer11node2 { hardware ok 19:50:56:bd:03:c3; MAC-ADDRESS 10.1.1.2; } FILENAME2: computer11node1 11:50:56:81:33:c5 computer11node2 11:50:56:81:33:c6 computer11node3 11:50:56:81:33:c7... (5 Replies)
Discussion started by: kenshinhimura
5 Replies

10. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url=https://qa.east.corp.com/prop/end west.url=https://qa.west.corp.com/prop/end south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies
clipboard(n)						       Tk Built-In Commands						      clipboard(n)

__________________________________________________________________________________________________________________________________________________

NAME
clipboard - Manipulate Tk clipboard SYNOPSIS
clipboard option ?arg arg ...? _________________________________________________________________ DESCRIPTION
This command provides a Tcl interface to the Tk clipboard, which stores data for later retrieval using the selection mechanism (via the -selection CLIPBOARD option). In order to copy data into the clipboard, clipboard clear must be called, followed by a sequence of one or more calls to clipboard append. To ensure that the clipboard is updated atomically, all appends should be completed before returning to the event loop. The first argument to clipboard determines the format of the rest of the arguments and the behavior of the command. The following forms are currently supported: clipboard clear ?-displayof window? Claims ownership of the clipboard on window's display and removes any previous contents. Window defaults to ".". Returns an empty string. clipboard append ?-displayof window? ?-format format? ?-type type? ?--? data Appends data to the clipboard on window's display in the form given by type with the representation given by format and claims own- ership of the clipboard on window's display. Type specifies the form in which the selection is to be returned (the desired "target" for conversion, in ICCCM terminology), and should be an atom name such as STRING or FILE_NAME; see the Inter-Client Communication Conventions Manual for complete details. Type defaults to STRING. The format argument specifies the representation that should be used to transmit the selection to the requester (the second column of Table 2 of the ICCCM), and defaults to STRING. If format is STRING, the selection is transmitted as 8-bit ASCII characters. If format is ATOM, then the data is divided into fields separated by white space; each field is converted to its atom value, and the 32-bit atom value is transmitted instead of the atom name. For any other format, data is divided into fields separated by white space and each field is converted to a 32-bit integer; an array of integers is transmitted to the selection requester. Note that strings passed to clipboard append are concatenated before conversion, so the caller must take care to ensure appropriate spacing across string boundaries. All items appended to the clipboard with the same type must have the same format. The format argument is needed only for compatibility with clipboard requesters that do not use Tk. If the Tk toolkit is being used to retrieve the CLIPBOARD selection then the value is converted back to a string at the requesting end, so format is irrelevant. A -- argument may be specified to mark the end of options: the next argument will always be used as data. This feature may be con- venient if, for example, data starts with a -. clipboard get ?-displayof window? ?-type type? Retrieve data from the clipboard on window's display. Window defaults to ".". Type specifies the form in which the data is to be returned and should be an atom name such as STRING or FILE_NAME. Type defaults to STRING. This command is equivalent to "selection get -selection CLIPBOARD". EXAMPLES
Get the current contents of the clipboard. if {[catch {clipboard get} contents]} { # There were no clipboard contents at all } Set the clipboard to contain a fixed string. clipboard clear clipboard append "some fixed string" You can put custom data into the clipboard by using a custom -type option. This is not necessarily portable, but can be very useful. The method of passing Tcl scripts this way is effective, but should be mixed with safe interpreters in production code. # This is a very simple canvas serializer; # it produces a script that recreates the item(s) when executed proc getItemConfig {canvas tag} { set script {} foreach item [$canvas find withtag $tag] { append script {$canvas create } [$canvas type $item] append script { } [$canvas coords $item] { } foreach config [$canvas itemconf $item] { lassign $config name - - - value append script [list $name $value] { } } append script } return [string trim $script] } # Set up a binding on a canvas to cut and paste an item set c [canvas .c] pack $c $c create text 150 30 -text "cut and paste me" bind $c <<Cut>> { clipboard clear clipboard append -type TkCanvasItem [getItemConfig %W current] # Delete because this is cut, not copy. %W delete current } bind $c <<Paste>> { catch { set canvas %W eval [clipboard get -type TkCanvasItem] } } SEE ALSO
interp(n), selection(n) KEYWORDS
clear, format, clipboard, append, selection, type Tk 8.4 clipboard(n)
All times are GMT -4. The time now is 04:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy