I’m trying the whole day to find a good way for parsing some strings with a shell script. the strings are used as calling parameter for some applications. they looks like: I’m only allowed to use shell-script. I tried to use some sed and cut commands but nothing works fine. My tries are like: that return the correct value of
Tag: sed
Linux piping data containing backticks
I’m piping output from one command into a second: mpc listall returns the following data (can output 1 or more lines): When piping it into the next command, it seems that my shell (Ash on BusyBox) converts the ยด into an asterisk, as I get the error Manually adding double quotes works! like this: So, I tried adding those by
Read first line in a file and append it to first occurrence of the search string and Repeat until EOF
I have a file with following lines in a text file in following format And a json file in following format Now i want output of json as follows So how can achieve this using bash? I’ve tried with following but it only appends last line of the file. Answer This will do it:
How to change *** to textbf with sed
I export results from my analysis into a table in Latex. I would like to be able to change all coefficients that are significant to ***, **, * to bold face text textbf. This requires me to search with sed and change the stars to wrap around the coefficient. I want to change 0.047$^{***}$ to textbf{0.047} I’ve been trying, sed
Extract a block from file between two lines
I have a file/output containing this : I would like to extract all public subnet id and print them without, and white space. I used this regex And the output is : But I would like to get this instead: In fact I told sed to replace spaces and newlines with nothing (s/[[:space:]]//g) and then it also replace the first
Why is my sed substitution with a & failing to execute?
I am trying to run following command on Linux Docker container but I am getting the following error: The file content I am running it for: I am doing it as suggested at – https://solveme.wordpress.com/2017/07/24/java-awt-awterror-assistive-technology-not-found-org-gnome-accessibility-atkwrapper-when-running-jasper-reports/ Can someone help me with it? Answer Just quote the command so & does not have an special meaning for Bash! What is exactly happening
sed command to replace all last lines with some new multi line strings after getting second pattern
I want to write a program to change systems ip address from dhcp/static to static only. my original file’s contents will be either this or it may be like this, Now, i want to change after [ipv4] pattern, so that after editing my file should looks like this Answer Here’s a Perl solution. It sets the record delimiter to 2
Split string in xml
I have xml file which contains data . I want to split only FATURANO Like that 6-R-7 and 4825 And this “4825” should have different name. I Need convert xml data like that but if u answer me only with first question how to split string correctly i will do other transpormation Answer With single xmlstarlet expression: ed – edit
Curl/sed command not processing inputs correctly
I’m having some trouble with getting this to do what I want it to do. So basically what I want is to use curl to get a .txt file from a url, then sort through it to find the word specified by the user input. Then mark all those words with a * and put them in a file specified
Editing single value in file in C efficiently
I have a C program that currently edits a single value in a parameter file by using sed through a system call. I’d like to change the program to use the C file libraries to edit this value, but the only way I know how to do this is by reading in the entire file, changing the value, and rewriting