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
Tag: string
Linux count files with a specific string at a specific position in filename
I have a directory which contains data for several years and several months. Filenames have the format yy/mm/dd, f.e. 20150415, 20170831, 20121205 How can I find all data with month = 3? F.e. 20150302, 20160331, 20190315 Thanks for your help! Answer A question mark is a wildcard which stands for one character, so as your format seems to be YYYYmmDD,
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
How do i concatenate a string in between to strings at run time?
I have use case where I need to check if a file exists. But the catch is, there are diffrent file that needs to checked for and each file will have its own method. I tried the above code snippet, the debug logs this test -e && echo file exists || echo file not found. String variable fileToCheck is not
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
Deleting strings from text file
I have a txt file, like this: I only want to keep: I tried: It works, but can’t get rid of the date. Answer Although you might prefer to get rid of more whitespace with:
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
How can I insert spaces or characters every “n” spaces while tailing a file?
I am tailing a log file and want to make it more readable. The current output is something like this: I want the output to be more like this: It would be great if sed could be used to insert the spaces. The spaces need to be every 8 characters — it will always be in binary data after the
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