Im testing my code for automation of the installation of a software In bashrc file below: Here im trying to add $SCALA_HOME/bin to PATH. this is the required output: the above code worked to append SCALA_HOME above path but for appending in the same line im not able to do please help me get the correct sed command to append
Tag: sed
Extract text between two known strings in a web page and store in a variable
The web page contains this line: var zx_fn = “string with any possible character”; I download the web page, then I try to to take the part between quotes and store it in a variable my code: It doesn’t work because it says: sed: can’t read And it returns the whole page content Also what’s better for this case? grep,
find matching text and replace next line in yml
I’m trying to find a line in a yml configuration file and replace the next line with a specific value. I tried sed, but it seems it is not replacing or not able to find the pattern. Below is the snippit of that yml file I want to change port value to 14081 for applicationConnectors as there is another port
How to find encapsulating function name from line number
I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file and here are the contents of the file foo.file Based on the above log file, I want
How To Replace Strings With X to Y Characters
I have data similar to the following: I am looking for a way to replace strings in field 2. If the number does not have 10-11 characters, I would like to replace it with 12223334444 so the output would be: My original thought was to use cut to get the second field and then use grep “[1-9]” or something similar
Replacement of PS1 variable in .bashrc using Sed or Perl
I am trying to replace a line in file and am running in to issues. Original File: Command I am running: Error message: I also tried sed: Result with Sed: Expected Result File: End Result This doesn’t have much to do with the question except to show folks what the PS1 will look like when working properly Answer For sed,
Export Curl information to file using sed
I am trying to get a dns address using curl and I would like to use that dsn address to replace a word in a .js file. So the .js file contains a word “hostname” and I would like to replace that with the dns address fetched from curl so what I am trying to do is this. sed ‘s/hostname/curl
Why isn’t this sed command working for the regex?
I want to remove the multi-line comments in Java using sed command. The regex is working if we use character ranges like a-zA-Z0-9 etc. but not in case of word character like wS. Test-File content: Command used : Expected results: Actual results: Answer You can use grep with a regex (-E) and inverted matches (-v), i.e.: Output:
How to use back-reference of sed replacement command correctly considering a special Regular Expression
I am learning the sed s/regexp/replacement/ command on linux. There are some numbers from phone.txt I’d like to use the regular expression (which I have tested on https://www.freeformatter.com/regex-tester.html) to match numbers which begin with (555). And then I want the output of these three parts of these matched number as: (an example for number (555)555-1212) I tried the following command:
Get a particular string from text file
I need to get a particular string from a text file. the content of my file is below : The command that i am trying is : Using this command, I am able to get that particular line in which my string is present. Here is the result of the awk command : What I want to grep is only