09-25-2007
Quote:
Originally Posted by
Jartan
Hi,
I have this line in a file called test.cfg
SOURCEFILE=/usr/platform/sun4v/driver/file.cfg
But i have many occurances of "SOURCEFILE" in test.cfg , i need to search only for this line and replace that line with
SOURCEFILE=/usr//driver/fileplatform/sun4x.cfg
again there are many occurences of sun4v in that file but i need to replace only in this line. I tried grep for "SOURCEFILE="and using perl -pi -e but it replaces wherever it finds "sun4v" but i want only on this line.
Please help me.
Thanks.
I am not sure I totally understand what you want to replace and how to find it but if you want to replace the whole line you can do:
sed 's/SOURCEFILE=\/usr\/platform\/sun4v\/driver\/file.cfg/SOURCEFILE=\/usr\/platform\/sun4x\/driver\/file.cfg/' test.cfg
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
I am hoping someone can provide some guidance on using context based search and replace to search for a pattern and then do a search and replace in the line that follows it. For example, I have a file that looks like this:
<bold>bold text
</italic>
somecontent
morecontent... (3 Replies)
Discussion started by: charissaf67
3 Replies
2. Shell Programming and Scripting
Hi All,
I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text.
An example of 4 lines in my file is:
1. MatchText_randomNumberOfText moreData ReplaceMe moreData
2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies
3. Shell Programming and Scripting
hai
i am very new to unix.
i am having two files like this.
first.properties
cache.ZA.TL_CCY=SELECT trim(CCY_CODE)||trim(COUNTRY_CODE)||trim(CITY_CODE) AS... (4 Replies)
Discussion started by: kkraja
4 Replies
4. Shell Programming and Scripting
Hi All,
I have a requirement where I have to find a pattern in a file and comment the whole line containing the search pattern. Any ideas in shell is welcome.
Thanks in advance,
Regards,
Arun (3 Replies)
Discussion started by: arun_maffy
3 Replies
5. UNIX for Advanced & Expert Users
Hi,
I need help. I have XML file as below
<a n="infoLevel">
<v s="true"/>
</a>
<a n="localAddr">
<v s="server.host.com"/>
</a>
<a n="ListenPort">
<v s="21111"/>
</a>
I need to find variable "ListenPort" in line and then replace... (4 Replies)
Discussion started by: rdtrivedi
4 Replies
6. Shell Programming and Scripting
There appears to be several threads that touch on what I'm trying to do, but nothing quite generic enough.
What I need to do is search through many (poorly coded) HTML files and make changes. The catch is that my search string may be on one line or may be on several lines.
For example there... (5 Replies)
Discussion started by: bisbell
5 Replies
7. Shell Programming and Scripting
Dear All,
i want to search particular string and want to replance next line value.
following is the test file.
search string is
tmp,???
,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50
tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies
8. UNIX for Advanced & Expert Users
Hi All,
i can replace a perticular value in sentence using perl.
perl -pi -e 's/old/new/' sample.txt
but i am not able to replace whole string by perl.
file1 contains "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.147.109.211)(PORT=1526))(CONNECT_DATA=(SID= MWDBD22)))". i... (3 Replies)
Discussion started by: arindam guha
3 Replies
9. Shell Programming and Scripting
I have a file which requires modification via a shell script.
Need to do the following: 0. take input from user for new text. 1. search for a keyword in the file. 2. replace the line next to this to this keyword with user supplied input.
for e.g., my file has the following text:
(some... (7 Replies)
Discussion started by: chingupt
7 Replies
10. 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
LEARN ABOUT DEBIAN
bbcombotest.cfg
BBCOMBOTEST.CFG(5) File Formats Manual BBCOMBOTEST.CFG(5)
NAME
bbcombotest.cfg - Configuration of bbcombotest tool
SYNOPSIS
$BBHOME/etc/bbcombotest.cfg
DESCRIPTION
bbcombotest(1) uses it's own configuration file, $BBHOME/etc/bbcombotest.cfg Each line in this file defines a combined test.
FILE FORMAT
Each line of the file defines a new combined test. Blank lines and lines starting with a hash mark (#) are treated as comments and ignored.
The configuration file uses the hostnames and testnames that are already used in your Xymon bb-hosts file. These are then combined using
normal logical operators - "||" for "or", "&&" for "and" etc.
A simple test - e.g. "Web1.http" - results in the value "1" if the "http" test for server "Web1" is green, yellow or clear. It yields the
value "0" if it is red, purple or blue.
Apart from the logical operations, you can also do integer arithmetic and comparisons. E.g. the following is valid:
WebCluster.http = (Web1.http + Web2.http + Web3.http) >= 2
This test is green if two or more of the http tests for Web1, Web2 and Web3 are green.
The full range of operators are:
+ Add
- Subtract
* Multiply
/ Divide
% Modulo
| Bit-wise "or"
& Bit-wise "and"
|| Logical "or"
&& Logical "and"
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
== Equal
There is currently no support for a "not" operator. If you need it, use the transcription "(host.test == 0)" instead of "!host.test".
NB: All operators have EQUAL PRECEDENCE. If you need something evaluated in a specific order, use parentheses to group the expressions
together.
If the expression comes out as "0", the combined test goes red. If it comes out as non-zero, the combined test is green.
Note: If the expression involves hostnames with a character that is also an operator - e.g. if you have a host "t1-router-newyork.foo.com"
with a dash in the hostname - then the operator-character must be escaped with a backslash '' in the expression, or it will be interpreted
as an operator. E.g. like this:
nyc.conn = (t1-router-nyc.conn || backup-router-nyc.conn)
EXAMPLE
WebCluster.http = (Web1.http || Web2.http)
AppSrvCluster.procs = (AppSrv1.conn && AppSrv1.procs) || (AppSrv2.conn && AppSrv2.procs)
Customer.cluster = WebCluster.http && AppSrvCluster.procs
The first line defines a new test, with hostname "WebCluster" and the columnname "http". It will be green if the http test on either the
"Web1" or the "Web2" server is green.
The second line defines a "procs" test for the "AppSrvCluster" host. Each of the AppSrv1 and AppSrv2 hosts is checked for "conn" (ping)
and their "procs" test. On each host, both of these must be green, but the combined test is green if that condition is fulfilled on just
one of the hosts.
The third line uses the two first tests to build a "double combined" test, defining a test that shows the overall health of the system.
FILES
$BBHOME/etc/bbcombotest.cfg
SEE ALSO
bbcombotest(1)
Xymon Version 4.2.3: 4 Feb 2009 BBCOMBOTEST.CFG(5)