Sponsored Content
Top Forums Shell Programming and Scripting replace (sed?) a string in file with multiple lines (string) from variable Post 302555688 by jforce on Thursday 15th of September 2011 10:10:41 AM
Old 09-15-2011
Quote:
Originally Posted by birei
Hi,

Use double quotes for the entire 'sed' command.
Code:
$ sed -i "s/STRING/$a/g" filename.ext

Regards,
Birei
I try double quotes but don't work

In my case
a=$(ewrwertwer trt erter ter ter tyer terter terter ter (werrewr) rwerwer werwer
asdas asd asd asd
werwerrweéé wéé)

Last edited by jforce; 09-15-2011 at 06:25 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Delete multiple lines containting a variable string using SED.

Good morning, Novice scripter in Unix here, and I've run into and sed task I can't quite wrap my head around. I'm pulling my hair out fast enough as it is and thought I would go to the knowledge bank. I have a sorted file that I'm trying to trim down by deleting any line whose first few... (2 Replies)
Discussion started by: selkirk
2 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 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

5. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

6. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

7. Shell Programming and Scripting

How to replace a string with a variable in a file using sed?

I have a file having some text like: PATH_ABC=/user/myLocation I have to replace "/user/myLocation" with a session variable say, $REPLACE_PATH, where $REPLACE_PATH=/user/myReplaceLocation The following sed command is not working. It is writing PATH_ABC=$REPLACE_PATH in the file ... (2 Replies)
Discussion started by: SKhan
2 Replies

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

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
XFERFAXSTATS(8) 					      System Manager's Manual						   XFERFAXSTATS(8)

NAME
xferfaxstats - summarize HylaFAX transmission accounting SYNOPSIS
/usr/sbin/xferfaxstats [ options ] [ files ] DESCRIPTION
xferfaxstats is a command script that prints a summary of the HylaFAX accounting statistics for transmitted jobs. The statistics can be sorted using one of several keys: the sender's account name (default), the job tag (useful when used for accounting purposes), the remote party's CSI, the called phone number, the output device used for the call, the communication speed, and the communication data format. Statistics are read from the file /var/spool/hylafax/log/xferfaxlog in the spooling area, unless filenames are specified on the command line. The following table is an example of the output from xferfaxstats (using the default sort key): Destination Pages Time Pg/min Errs TypRate TypData cadsmith@esd.sgi.com 34 24:05 1.4 0 9600 1-D MH ctb@corp.sgi.com 32 20:43 1.5 2 9600 2-D MR edmark@esd.sgi.com 42 29:30 1.4 3 9600 1-D MH fredc@mfg.sgi.com 157 1:37:52 1.6 0 9600 2-D MR jlw@engr.sgi.com 81 57:29 1.4 1 9600 1-D MH jlw@wpd.sgi.com 346 3:57:57 1.5 100 9600 1-D MH karlton@asd.sgi.com 68 36:57 1.8 0 9600 1-D MH kerrie@mfg.sgi.com 48 32:29 1.5 1 9600 2-D MR kgraf@mfg.sgi.com 128 1:48:21 1.2 2 9600 1-D MH kubey@wpd.sgi.com 264 3:22:13 1.3 6 9600 1-D MH loki@wpd.sgi.com 205 2:56:45 1.2 5 9600 2-D MR moondog@esd.sgi.com 112 1:23:01 1.3 4 9600 2-D MR mpolen@mti.sgi.com 122 1:39:32 1.2 1 9600 1-D MH nancyf@mfg.sgi.com 174 2:08:44 1.4 2 9600 2-D MR paulh@mfg.sgi.com 56 1:29:24 0.6 0 9600 2-D MR richardn@mfg.sgi.com 34 24:42 1.4 1 9600 1-D MH rosa@corp.sgi.com 32 28:00 1.1 2 9600 1-D MH sam@asd.sgi.com 65 46:25 1.4 5 9600 1-D MH seth@asd.sgi.com 34 25:04 1.4 0 9600 1-D MH -------------------------------------------------------------------------- Total 2034 25:49:13 1.3 135 The first column column shows the sort key value used (the sender's identity here, but otherwise the destination phone number, remote CSI, etc.). The Pages column is the total number of good pages transmitted. The time column shows the total amount of time spent transmitting. The Pg/min column displays the average transfer rate. The Errs column indicates how many errors were encountered while transmitting fac- simile. (Note that this statistic does not include problems encountered while placing a call; e.g. busy signals.) The TypRate column displays the most common communication speed with which facsimile were transmitted. The TypData column shows the most common data format in which facsimile data were transmitted. Account names other than ``root'' and ``guest'' can be automatically mapped to a canonical format in which the host name is removed and identical addresses in the same domain are merged together (i.e. for NIS environments). For example, ``sam@flake.asd.sgi.com'' and ``sam@foobar.asd.sgi.com'' are both mapped to ``sam@asd.sgi.com'' with the associated statistics accumulated. Identical account names in different domains generate a warning; e.g. ``loki@wpd.sgi.com'' and ``loki@corp.sgi.com''. The above mapping is done only if the -map option is specified, by default account names are not altered. OPTIONS
-age days Show information only for the facsimile transmitted in the last specified number of days. -csi* Sort output by the remote party's CSI. -dest* Sort output by the phone number called. -dev* Sort output by the output device (i.e. modem) used. -format Sort output by the negotiated data format. -job* Sort output by client-specified job tag identifiers. -nomap Do not perform the account name mapping by which statistics for the ``root'' and ``guest'' accounts are merged and leading hostname part of domain names are stripped. This is the default behavior. -map Perform the account name mapping by which statistics for the ``root'' and ``guest'' accounts are merged and leading hostname part of domain names are stripped. -send* Sort output by sender's account name (default). -since time Show information only for the facsimile transmitted since the specified time; where time is of the form ``MM/DD/YY HH:MM'' (the date(1) format string %D %H:%M). -end time Show information only for the facsimile transmitted before the specified time; where time is of the same form as since. -speed Sort output by the signalling rate. DIAGNOSTICS
``Warning, address clash, "%s" and "%s".'' During address mapping two mapped addresses were found for the same account name. ``Warning, weird user address/name "%s".'' During address mapping an address was encountered that multiple ``@'' symbols in it. NOTES
The sender field does not necessarily represent the submitter's actual identity. For example, it reflects the value given by the send- fax(8) ``-f'' option. Be cautious that this field is not utilized for auditing if the fax user base is not trusted. FILES
/var/spool/hylafax spooling area log/xferfaxlog default file from which to read statistics SEE ALSO
faxq(8), faxsend(8), recvstats(8), hylafax-log(5) May 12, 1996 XFERFAXSTATS(8)
All times are GMT -4. The time now is 05:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy