Sponsored Content
Top Forums Shell Programming and Scripting How to find a certain string in a file and replace it with a value from another file using sed/awk? Post 302481282 by paramad on Friday 17th of December 2010 05:39:43 AM
Old 12-17-2010
hi anurag,
u r right... it will be like this:
data.txt:

main: ARG 1
function1: F1 1
function2: F1' 1
main: OUT 0
function1: F2 1
function2: F2' 0

now it becomes little difficult actually:
i have to replace ARG in the first file(see main post) with the corresponding value for ARG ie '1' . similarly for F1, value 1 etc. now ill the previous code work? i have to match the string and get the corresponding value .. how will i do that?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find and replace a string in a file without the use of temp file

Hi - I am looking for a replacing a string in a in multiple *.sql files in directory with a new string without using a temporary file Normally I can use sed command as below for W in ls `FILE*.sql` do sed 's/OLD/NEW/g' $W > TEMPFILE.dat mv TEMPFILE.dat $W done But Here in my... (9 Replies)
Discussion started by: raghutapal
9 Replies

2. Shell Programming and Scripting

Using sed to replace a string in file with a string in a variable that contains spaces

Hi, i call my shell like: my_shell "my project name" my script: #!/bin/bash -vx projectname=$1 sed s/'PROJECT_NAME ='/'PROJECT_NAME = '$projectname/ <test_config_doxy >temp cp temp test_config_doxy the following error occurres: sed s/'PROJECT_NAME ... (2 Replies)
Discussion started by: vivelafete
2 Replies

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

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

5. Shell Programming and Scripting

How to replace a string containing @ in a file using sed ?

I have a list of names and email addresses. Sample File - username=poga--poga@yahoo.com new-york,US 512834 username=poga123--poga123@hotmail.com new-jersey,US 0894753 Requirement is to replace the email ids as dummy_username@xyz.com using sed only. Output File -... (4 Replies)
Discussion started by: poga
4 Replies

6. Shell Programming and Scripting

sed or awk to replace a value in a certain line from another file containing a string

Hi experts, In my text file I have the following alot of lines like below. input.k is as follows. 2684717 -194.7050476 64.2345581 150.6500092 0 0 2684718 -213.1575623 62.7032242 150.6500092 0 0 *INCLUDE $# filename... (3 Replies)
Discussion started by: hamnsan
3 Replies

7. Shell Programming and Scripting

Help with Passing the Output of grep to sed command - to find and replace a string in a file.

I have a file example.txt as follows :SomeTextGoesHere $$TODAY_DT=20140818 $$TODAY_DT=20140818 $$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script. (It would even be better if I could pass... (5 Replies)
Discussion started by: SriRamKrish
5 Replies

8. Shell Programming and Scripting

Perl script to read string from file#1 and find/replace in file#2

Hello Forum. I have a file called abc.sed with the following commands; s/1/one/g s/2/two/g ... I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat sed -f abc.sed abc.dat >... (10 Replies)
Discussion started by: pchang
10 Replies

9. Shell Programming and Scripting

Replace string in XML file with awk/sed with string from another

Sorry for the long/weird title but I'm stuck on a problem I have. I have this XML file: </member> <member> <name>TransactionID</name> <value><string>123456789123456</string></value> </member> <member> <name>Number</name> ... (9 Replies)
Discussion started by: cozzin
9 Replies

10. Shell Programming and Scripting

Replace string of a file with a string of another file for matches using grep,sed,awk

I have a file comp.pkglist which mention package version and release . In 'version change' and 'release change' line there are two versions 'old' and 'new' Version Change: --> Release Change: --> cat comp.pkglist Package list: nss-util-devel-3.28.4-1.el6_9.x86_64 Version Change: 3.28.4 -->... (1 Reply)
Discussion started by: Paras Pandey
1 Replies
XML::Easy::Classify(3pm)				User Contributed Perl Documentation				  XML::Easy::Classify(3pm)

NAME
XML::Easy::Classify - classification of XML-related items SYNOPSIS
use XML::Easy::Classify qw( is_xml_name check_xml_name is_xml_encname check_xml_encname is_xml_chardata check_xml_chardata is_xml_attributes check_xml_attributes is_xml_content_object check_xml_content_object is_xml_content_twine check_xml_content_twine is_xml_content check_xml_content is_xml_element check_xml_element ); if(is_xml_name($arg)) { ... check_xml_name($arg); if(is_xml_encname($arg)) { ... check_xml_encname($arg); if(is_xml_chardata($arg)) { ... check_xml_chardata($arg); if(is_xml_attributes($arg)) { ... check_xml_attributes($arg); if(is_xml_content_object($arg)) { ... check_xml_content_object($arg); if(is_xml_content_twine($arg)) { ... check_xml_content_twine($arg); if(is_xml_content($arg)) { ... check_xml_content($arg); if(is_xml_element($arg)) { ... check_xml_element($arg); DESCRIPTION
This module provides various type-testing functions, relating to data types used in the XML::Easy ensemble. These are mainly intended to be used to enforce validity of data being processed by XML-related functions. There are two flavours of function in this module. Functions of the first flavour only provide type classification, to allow code to discriminate between argument types. Functions of the second flavour package up the most common type of type discrimination: checking that an argument is of an expected type. The functions come in matched pairs. FUNCTIONS
Each of these functions takes one scalar argument (ARG) to be tested. Any scalar value is acceptable for the argument to be tested. Each "is_" function returns a simple truth value result, which is true iff ARG is of the type being checked for. Each "check_" function will return normally if the argument is of the type being checked for, or will "die" if it is not. is_xml_name(ARG) check_xml_name(ARG) Check whether ARG is a plain string satisfying the XML name syntax. (Such names are used to identify element types, attributes, entities, and other things in XML.) is_xml_encname(ARG) check_xml_encname(ARG) Check whether ARG is a plain string satisfying the XML character encoding name syntax. is_xml_chardata(ARG) check_xml_chardata(ARG) Check whether ARG is a plain string consisting of a sequence of characters that are acceptable to XML. Such a string is valid as data in an XML element (where it may be intermingled with subelements) or as the value of an element attribute. is_xml_attributes(ARG) check_xml_attributes(ARG) Check whether ARG is a reference to a hash that is well-formed as an XML element attribute set. To be well-formed, each key in the hash must be an XML name string, and each value must be an XML character data string. is_xml_content_object(ARG) check_xml_content_object(ARG) Check whether ARG is a reference to an XML::Easy::Content object, and thus represents a chunk of XML content. is_xml_content_twine(ARG) check_xml_content_twine(ARG) Check whether ARG is a reference to a twine array (see "Twine" in XML::Easy::NodeBasics), and thus represents a chunk of XML content. is_xml_content_array(ARG) Deprecated alias for "is_xml_content_twine". is_xml_content(ARG) check_xml_content(ARG) Check whether ARG is a reference to either an XML::Easy::Content object or a twine array (see "Twine" in XML::Easy::NodeBasics), and thus represents a chunk of XML content. is_xml_element(ARG) check_xml_element(ARG) Check whether ARG is a reference to an XML::Easy::Element object, and thus represents an XML element. SEE ALSO
Params::Classify, XML::Easy::NodeBasics AUTHOR
Andrew Main (Zefram) <zefram@fysh.org> COPYRIGHT
Copyright (C) 2009, 2010, 2011 Andrew Main (Zefram) <zefram@fysh.org> LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-11-16 XML::Easy::Classify(3pm)
All times are GMT -4. The time now is 02:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy