I want to replace $foo with bar. This works fine. But this command does not work fine when I use the -r option. Why doesn’t this work. Here is an example of what works with -r option. The real question is: Why does $ need to be escaped only while using the -r option. What would $ mean otherwise with
Tag: regex
BASH regex check not matching on linux
I have been scripting something in BASH and I have found a strange bug. I have been developing on Mac (El Capitan) and everything is working flawlessly. But deployment on Ubuntu 16.06 server is failing and I have no idea why. My code follows for input 6LfMYB8TAAAAACRZ9bP-0GN9y4zKUYPtj255-e8A this fails. And failure happens on server only and not on the development
Insert space between numbers after matching specific pattern [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago. Improve this question I have the following temperature data that needs to be manipulated. Thought about using sed to insert a space in
Negative lookbehind assertion regex has unexpected result with grep -P
I’m testing the following negated lookbehind assertion and I want to understand the result: it prints out I was expecting that only the two first foo would be printed, ‘echo foo foofoo’ but not the third one, because my assertion is supposed to mean find ‘foo’ that is not preceded by a ‘foo’. What am I missing? why is the
Finding the number of xml files having a particular word in a directory
I read Chris Maes answer on how to a grep for a particular word in any file/files contained in a directory, and it worked. But, what is the way of finding the names of the files and the total number of files containing that word ? Please correct me if I am wrong. Thanks in advance !! Answer You just
How can I match this pattern of file name in a directory, and output the matched?
there are many of files in this directory: and i want to make a list which just contains those files which have the pattern of: to match the file names such like: how can I use regexp to achieve this goal? Maybe we can use this syntax: Answer In regexp land, many roads lead to rome. 🙂 ^ marks the
search numbers with egrep and regular expression
Given a file file1 with this text: I want to use egrep to search all the numbers that start with 5 and end with 1. I have tried: Answer This regex will work Regex Breakdown
searching a file in linux
I want to find in the system a file, and I know part name of it. How could I do that? I tried unsuccessfully the command: The problem is probably very easy however I cannot find a decent tutorial on searching files in linux. Please tell me what command solves my problem and if you know a good tutorial so
U-Boot version extraction for comparision
I am trying to extract U-Boot version from its binary for comparison, consider that exact string what I want to search is as follow, so I wrote command with regex as follows, However I don’t see any output for that above command, I could make below command work which extracts version only by comparing versions and not looking for date
How to replace special characters to underscore(_) perl
Using above code i am not able to handle this “Monday_øå_Tuesday_Wednesday” The output should be : Answer You can use W to negate the w character class, but the problem you’ve got is that w doesn’t match your non-ascii letters. So you need to do something like this instead: Outputs: This uses a unicode property – these are documented in