I have a folder which is full of *.java files. it has the following method in it: i wanted to change this as following: I have searched in the forum and found some solutions, replce string is what i wanted so tried the following: But it throwing me the following error: I guess the old_string and new_string formates are the
Tag: replace
Search and Replace ( multiple lines )
Hello StackOverflow Community! I’m working on a bash script to change in Dynamic text file, I want to replace multiple lines with one line. Ex: This example, I want to replace THIS With KKKKK Before script After script I found a script to replace using ( sed ) but it doesn’t replace multiple lines. NOTE: I’m a beginner at scripting
Replace certain line in a text with a certain line in another text
Taking off from this question, I want to replace a certain line in one text file with another line from another text file. Example: text1 contains: text2: I want to replace the 2nd line in text1 with the second line from text2, the solution in the above mentioned question works by adding all the content of text2 in place of
Insert text if column contains a number
I have a tab-delim file that looks like this It should be three columns but some rows are missing the second column (bacterial taxonomy). For these rows I want to move the number to a third column and insert some text (such as Unclassified). I have been attempting to modify some commands I found online to insert Unclassifiedt before any
Is it possible to set an alias for a string?
As I’m so lazy, I don’t want to type 192.168.1 everytime anymore. I tried this: root@kali:~# alias “ip” = “192.168.1” That does not seem to work. As an example off what I try to accomplish: I don’t want to type this anymore: root@kali:~# hping3 -S –scan 1-1000 192.168.1.133 But instead shorter: root@kali:~# hping3 -S –scan 1-1000 ip.133 Answer add ip=”192.168.1″
ignoring variable containing and multiple spaces usnig sed command
I have two variables, i want to replace ESX_10.2.3.4@10.52.33.21 with new pool ser/@10.25.89.322 and also want to remove space before new word. i have tried like, and I don’t want to delete space ,just want to replace as it is(except space before “new”). Answer Give a try to this: It is removing the space in the first occurrence of new
Replacing strings with special characters in command line sed
I want to uncomment a line of a config file by replacing the line %% {some_string, []}, with {some_string, []} in the command line. I have tried a few different formats using sed: sed ‘s/%% {some_string, []},/{some_string, []}/’ filename sed “s/%% {some_string, []},/{some_string, []}/” filename sed “s/’%% {some_string, []},’/'{some_string, []}’/” filename sed ‘s/”%% {some_string, []},”/”{some_string, []}”/’ filename but every time
Inserting text in a ‘find’ command search
I have a find string that finds all the instances of a particular filename in a path, like so: I need to return the result with ‘FINENAME=’ prepended on each line. Having a hard time figuring the best way. Answer Note that if you have a directory named /opt/logs (and you’re not trying to look in /opt/logs-foo/ and /opt/logs-date, or
find and replace a String in vi editor on linux?
i am trying to replace String with new String in Linux vi editor but getting following error. Answer I’d guess the reason you’re getting that error message is because you intend to replace the string on all lines, not just the current one. In order to search all lines, add a % to your command:
I am trying to replace a string in a file via shell script where a part of the string is unknown
I have tried a few ways with sed as below without success: I do not know the value behind “=” which can have up to 2 digits. Before and after the string there is a space, and the string always starts with “device.value=” PS: The file is a one liner with many values seperated through a space. I would appreciate