remove the line
hi all
how to remove the line first we have to search the line if the line exist remove the line else dont do anything. for example "disable_from_plugins" , this is the word containing the line search the line and delete.. programatically can you please help me thank you in advance |
Something like this would do. You didn't mention which language you are using, so I will give you the solution in a random language. I'm sure it will help you:
Code:
Public Function DeleteLine(fName As String, LineNumber As Long) _ |
hi i tried up to this
Code:
cat munna.c | grep disable_from_plugins Quote:
and save the file.. and if the word not find.... dont do any thing.. i prefer c or script. please help me thank you in advance |
sed -i '/disable_from_plugins/d' munna.c
|
Quote:
i have another problem with this i would not like to remove the line. just wanna do some changes in the line.. for example "disable_from_plugins" , this is the word containing the line search the line and change the line i.e rame("rr.disable_from_plugins", 2); to "rame("rr.disable_from_plugins", 1);" and save by programatically can you please help me thank you in advance |
simple SED script
This simple script takes the string "Copyright 1999-2005 - All rights reserved" from all the html files in the directory where it is run and replaces it with "Copyright 1999-2007 - All rights reserved" and makes a backup as well... Hope it is of use.
for file in *.html do cp $file $file.bak && sed 's/Copyright 1999-2005 - All rights reserved/Copyright 1999-2007 - All rights reserved/g' $file.bak >$file done |
Quote:
previously i used sed -i '/disable_from_plugins/d' munna.c to delete the line but i would like to change the text in that line and save in that file only.. i dont wanna use redirecting file.. can you help me like one line command to do this operation ... thank you in advance |
sed in one line
AN IMAGINARY FILE CONTAINING: /usr/local/bin
The file name of the imaginary file is old - The one line command to change this file is: sed 's|/usr/local/bin|/common/bin|' <old >new If you can do it without the redirect (I assume you mean <old >new I am uncertain... |
Quote:
i tried like this Quote:
i would like to save the output in that file by replacing the line.. can you help me thank you in advance |
Perhaps you should at least read "sed --help". Note the "-i" option.
|
My all-time favorite tutorial on SED:
http://www.grymoire.com/Unix/Sed.html |
Try this
sed -i 's#rame("rr.disable_from_plugins", 0);#ame("rr.disable_from_plugins", 2);#g' simple.txt
Copy the line Go to CLI Press CTRL+SHIFT+V Press <Enter> Should work... Unless the file contains the # I used as the delimiter.... |
One little thing to notice
I removed the / in front of rame....
|
Quote:
Code:
s10=g_strconcat("sed -i 's/rame("rr.disable_from_plugins", 2);/rame("rr.disable_from_plugins", 1)/g' ","/home/munna/Desktop/simple.txt",NULL); Quote:
or else can you me other solution for this? i would like to change 1 instead of 2 in that perticular line rame("rr.disable_from_plugins", 2); how can i do this please help me thank you in advance |
All times are GMT -5. The time now is 04:39 AM. |