Skip to content
Advertisement

Tag: string

Using sed regex for string replacement

I am trying to replace a string in the config file. I would like to run something like this: OS (docker image php:8.1-apache-buster) Debian GNU/Linux 10 (buster) sed (GNU sed) 4.7 Packaged by Debian Possible inputs: Example output (any user given value): Example cmd: Joining regex with strings does not work here. It works when I run string replace without

linux replace string in files recursively

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

bash extract version string & convert to version dot

I want to extract version string (1_4_5) from my-app-1_4_5.img and then convert into dot version (1.4.5) without filename. Version string will have three (1_4_5) or four (1_4_5_7) segments. Have this one liner working ls my-app-1_4_5.img | cut -d’-‘ -f 3 | cut -d’.’ -f 1 | tr _ . Would like to know if there is any better way rather

The use of const char* vs. string literals

I’m using an external Modbus library – written in C – to connect to a microntroller Modbus slave from a Linux machine, using a serial connection. I’m also using wxWidgets to create an application on the Linux machine, which runs a Modbus master in the background. One of the Modbus functions accepts the name of the serial port the Modbus

Search string in file via bash but only work match

Find the only string name based on the sub string name in a file. Command used: What works: File content: Output (desired output): What does not work: File content: Output: Need output SomeApi-CURRENT.war Answer It appears, you are interested in the docBase attribute of your xml elements. Specifically those where the value string contains “current” as a substring. But this

grep string after first occurrence of numbers

How do I get a string after the first occurrence of a number? For example, I have a file with multiple lines: I want to get the following output: Thank you. Answer Imagine the following two input files : A quick solution with awk would be : This line substitutes the first string of anything that does not contain a

Advertisement