Skip to content
Advertisement

Tag: regex

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

The sed command is not working with regex

I’m parsing the output of a HTTP GET request with sed to retrieve the contents of a given html tag. The result of that request is like this: “<!DOCTYPE html><html><body><h1>Hello!</h1><p>v1.0.4-b</p></body></html>” And I want to retrieve the version number inside the p element. However, sed seems to have a bug in regex parsing. When I use: sed ‘s/.*<p>//’ It correctly replaces

Regular expression operator {} in linux bash

I’m having some problems with the {} operator. In the following examples, I’m trying to find the rows with 1, 2, and 2 or more occurrences of the word mint, but I get a response only if I search for 1 occurrence of mint, even though there are more than 1 per row. The input I am processing is a

reading and analyzing a text file with bash script

I want to read a log file and want to extract 5-6 number digit that is written right next after the keyword “salary”. And then want to analyze if the salary is above 2000. If there is even one above 2000, it is a MNC otherwise unknown. After writing the salary, the line ends mostly but sometimes there is an

How to apply regex to specific column in awk

This will colorize the output of ls -lhAXF How to apply the color to specific type of item using regex, for example i want the folder to be green, the .config folder red, the regular file blue or something like that. folder – match $9 column containing ‘/’ in the end of word hidden folder – match $9 column containing

How to use regex to match both filename and file content in Linux? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I want to find files that contain the word ‘virus’ but not ‘antivirus’ (case insensitive) in both their filename and their content. Thanks for your

Advertisement