07-07-2011
perl: replace multiple word on a line
Hi All,
If I have a line as following:
( MA "vertical" )
How can I convert it to as below:
( BC "horizontal" )
Thanks,
--Michael
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Could someone tell me how to replace a word at a particular line by a single SED or AWK command?
e.g. I have a file with the contents below:
$ cat file1
111 AAA
333 CCC
222 BBB
444 CCC
I want to replace the word "CCC" with a blank to get the desired output below:
111 AAA
333 CCC... (3 Replies)
Discussion started by: stevefox
3 Replies
2. Shell Programming and Scripting
Hi i am trying to write a perl program where i have to open a
1)directory "unit"
2) rename the files in the dir say file1.txt;file2.txt...file5.txt
to file1_a.txt;file2_a.txt,....file5_a.txt ;file1_x.txt ;file2_x.txt
3) open these renamed files and replace the words
lets say file1_a.txt... (7 Replies)
Discussion started by: madhul2002
7 Replies
3. Shell Programming and Scripting
I have a file like this..
Maharastra Mumbai worli
Maharastra Mumbai navy
maharatra Pune
Maharastra Nagpur
Karnataka Bangalore
Karnataka Mysore
Karnataka Mangalore
Punjab Amritsar
punjab Jalandar
my expected outcome should be like this
Maharastra Mumbai worli
---------- ... (9 Replies)
Discussion started by: geeko
9 Replies
4. Shell Programming and Scripting
How do I replace only if the keyword is at the begining of a line?
Code:
--
a = “This is a print statement”
print a
--
What if I want to replace print by #print only in the second line i.e only if the line starts with that keyword.
Please help me out. I'm new to SED.
-----Post... (5 Replies)
Discussion started by: alexzubin
5 Replies
5. Shell Programming and Scripting
Hi folks,
have a look into the attachment, i am not familiar with unix, can you please help me in this regard.
thanks in advance, :)
regards,
Geeko (4 Replies)
Discussion started by: geeko
4 Replies
6. Shell Programming and Scripting
Hi,
I have been trying to replace the key word
"SQL> spool off "
with
"/
show errors"
with out double quotes in all the files in a directory.
above show erros should be displayed next line
Could you please help me how to do that.
I have tried something like this... (3 Replies)
Discussion started by: pointers
3 Replies
7. UNIX for Advanced & Expert Users
Hi,
I want to search for a specific word in file and replace whole line with new text.
e.g.
1) I have file with below lines
APP=ABCD 12/12/2012
DB=DDB 01/01/2013
I need perl command which will check for APP=$VAL and replace whole line with APP=$NEWVAL $NEWDT
Simlarly need a... (2 Replies)
Discussion started by: mgpatil31
2 Replies
8. Shell Programming and Scripting
All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed...
I have an input file similar to:
&LOG
&LOG Part: "@DB/TC10000021855/--F"
&LOG
&LOG
&LOG Part: "@DB/TC10000021852/--F"
&LOG Cloning_Action: RETAIN
&LOG Part: "@DB/TCCP000010713/--A"
&LOG
&LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies
9. UNIX for Beginners Questions & Answers
my inputfile:
This is a test and only a test for production - prod.
echo "This is a test and only a test for production - prod" | perl -pi -e 's/prod/test/g'
outputfile:
This is a test and only a test for testuction - test
I only want to replace prod, not production.
I also... (3 Replies)
Discussion started by: loktamann
3 Replies
10. UNIX for Beginners Questions & Answers
I have query to replace the first word in line using below code but its replace the middle word too
sed -i 's/load /# LOAD/' /tmp/check.sql
Query 1 :
UPDATE accheadcon_data_last_upload SET last_upload_date = '2017-07-23'
Replace to
UPDATE accheadcon_data_last_up# LOAD SET... (1 Reply)
Discussion started by: kaushik02018
1 Replies
LEARN ABOUT OPENSOLARIS
cglue
CGlue(3U) InterViews Reference Manual CGlue(3U)
NAME
CGlue - connector glue
SYNOPSIS
#include <Unidraw/cglue.h>
DESCRIPTION
CGlue defines a natural size, elasticity (its rate of stretching and shrinking relative to other CGlue), and deformation limits (total
amount it can stretch and shrink) in both the horizontal and vertical dimensions. CGlue can be interposed between two connected connectors
to augment their connectivity semantics; it acts like two non-linear springs, one horizontal and one vertical, connecting the connectors'
centers.
PUBLIC OPERATIONS
CGlue(
float hnat = 0, float vnat = 0,
float hshr = 0, float hstr = 0,
float vshr = 0, float vstr = 0,
float hshrlim = 0, float hstrlim = 0,
float vshrlim = 0, float vstrlim = 0
)
CGlue(const Shape&)
Instantiate CGlue, providing the requisite parameters explicitly or inferring them from a Shape object. If a shape is supplied,
then the CGlue adopts the shape's natural size, and it assigns the shape's stretchability and shrinkability values to its corre-
sponding CGlue elasticity members to obtain a proportionately equivalent elasticity. It also assigns the shape's stretchability and
shrinkability values to its deformation limit members. The parameters are described below:
hnat, vnat: horizontal and vertical natural sizes, screen units
hshr, vshr: horizontal and vertical shrinking rate, constant units
hstr, vstr: horizontal and vertical stretching rate, constant units
hshrlim, vshrlim: horizontal and vertical shrink limit, screen units
hstrlim, vstrlim: horizontal and vertical stretch limit, screen units
CGlue* Copy()
Create a copy of this CGlue instance.
void Rigid()
Set all elasticity and deformation limits equal to zero.
void Interpose(const CGlue* glue)
Change this instance's attributes to reflect the series combination of this and glue.
SEE ALSO
Connector(3U), Shape(3I)
Unidraw 23 November 1990 CGlue(3U)