09-25-2007
search and replace the whole line
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/platform/sun4x/driver/file.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.
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 OPENSOLARIS
device_remap
device_remap(1M) System Administration Commands device_remap(1M)
NAME
device_remap - administer the Solaris I/O remapping feature
SYNOPSIS
/usr/platform/sun4v/sbin/device_remap [-v | -R dir]
DESCRIPTION
Certain multi-node sun4v platforms, such as T5440 and T5240 servers, have an integrated PCI topology that cause the I/O device paths to
change in a CPU node failover condition. The device remapping script, device_remap, remaps the device paths in /etc/path_to_inst file and
the symlinks under /dev to match the hardware.
OPTIONS
The following options are supported:
-v
Displays the /etc/path_to_inst and /dev symlink changes.
-R dir
Perform remapping on the /etc/path_to_inst and /etc/path_to_inst files in the root image at dir.
USAGE
The primary function of device_remap is to remap the device paths in the /etc/path_to_inst file and the symlinks under /dev in a CPU node
failover condition to match the hardware.
After adding CPU node(s) or removing CPU node(s), boot the system to the OBP prompt and use the following procedure:
1. Boot either the failsafe miniroot using: boot -F failsafe , or an install miniroot using boot net -s or similar command.
2. Mount the root disk as /mnt.
3. Change directory to the mounted root disk:
# cd /mnt
4. Run device_remap script:
# /mnt/usr/platform/sun4v/sbin/device_remap
5. Boot the system from disk.
All the error messages are self-explanatory, except for the error message "missing ioaliases node" which means the firmware on the system
does not support device remapping.
EXAMPLES
Example 1 Displaying Changes Following Failover
The following command displays the path_to_inst and /dev changes following a CPU node failover.
# device_remap -v
Example 2 Changing Directory Prior to Any Changes
The following command changes the directory on which the boot image is mounted prior to making any changes.
# device_remap -R /newroot
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWkvm.v |
+-----------------------------+-----------------------------+
|Interface Stability |Unstable |
+-----------------------------+-----------------------------+
SEE ALSO
boot(1M), attributes(5)
SunOS 5.11 24 Dec 2008 device_remap(1M)