How to find a match string in conf file
Heloo guys
I got one file test.conf. How i 'm going to find a string e.g "ServerID" inside test.conf using command line?? |
Hi,
You can try cat filename | grep string Prakash. |
UUOC (useless use of cat)
Try grep string filename |
Spec file script to check the string
thank your for the quick reply. Both solution is working finee :)
I'm now trying to build a rpm file.In my spec file, i would like to check the "serverID" string it exist or not in my "test.conf" file. Now, i 'm wondering how to give a return true status if "serverID" string is exist on my test.conf file using the solution above.Then it will remove the string |
Using an if-then test, you can evaluate the exit status of a command. For example:
Code:
if grep string filename Code:
sed 's/string_to_delete//g' filename The problem is to choose a regexp that matches only the string you want to delete. Can you provide a real example of what should be the content (or a relevenat part of it) of the file and the string to match? |
remove a whole string using keyword
Quote:
Thanks for your reply.It give me a more clear idea how to this. Using the "sed" command, in my test.conf i got this string "Serverid=[N]" actually the N is variable and it's value are not fixed Code:
sed -i 's/ServerID//g' filename It only remove "ServerID".Test conf output will be "=[n]". How i'm going to remove the whole string by defining "ServerID" only |
Try
sed -i 's/ServerID.*//' filename (untested) |
All times are GMT -5. The time now is 04:16 AM. |