Skip to content

Tag: regex

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 last year. 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 help.

bash – print regex captured groups

I have a file.xml so composed: I need to extract the following information: mayor_and_minor_release_number –> 1.0 patch_number –> 13 suffix –> -alpha I’ve thought the cleanest way to achieve that is by mean of a regex with grep command: I’ve checked with regex101 the correctness of this regex and actually it seems to properly capture the 3 fields I’m looking

Remove ” and n using sed

How to replace the below text using sed or in any other method. I need to replace the above to be like Answer A or . needs to be escaped in regex pattern. You may use this sed: You may consider this awk to remove ” and n characters anywhere in the file: