I am struggling with the following task(I’ve been searching for answer for a while). The search is for text between START_PATTERN and END_PATTERN1 Having a file structured like this: The task would be to restart search if END_PATTERN2 is found. Thus the command output should be: Thank you for your time! Answer this line should work for your example: test:
Tag: regex
Grouping and deleting Files
I have to come up with a solution to delete all files but the newest 2 in a directory stucture of our owncloud. The be exact – its the file versioning folder. There are files in one folder with the following structure: Filename.Ext.v[random_Number] The hard part is that there are different files in one folder I need to keep. IE:
sed substitute with partial string
Is it possible to replace the last 5 characters of the line with the last 4 characters of the line in sed? My filenames can be any length but the end is always predictable i.e. the part I want to substitute is always 5 characters from the end Answer Just match them separately, and omit the undesired character: Another approach
How to delete prefix, suffix in a string matching a pattern and split on a character using sed?
I have the following string, which is the output of a cassandra query in bash I want to split this string so as to remove the string in the beginning till the last + symbol and then remove the tail end, which is (XYZ rows). So, the string becomes A|1|a B|2|b C|3|c D|4|d. Now, I want to split this string
grep mac address – 2 consecutive lines
My file consists of scan results. Each result can have 4-20 lines I want to filter only MAC addresses for Successful (Passed scans) My file: I would like to extract list of mac addressees that Passed scans. So in example if line contains “PASSED” and next line or 2 contain mac address … print mac addresses. I would be grateful
How to GREP words, not lines, that contain specific characters, and print entire word
I have a file with tons of lines and words such as this example: What I want to do is list only the word (assuming each 4 character bundle is a word) that contains a specific number, such as 35. In this example, I would want the result printed to be: I have tried a few different ways such as
Complex regular subexpression recursion limit (32766) exceeded at
I have a perl script which performs a pgrep as follows: However when launch the script am having the following error/warning: Complex regular subexpression recursion limit (32766) exceeded at /home/k.sewnundun/test.pl line 16. Complex regular subexpression recursion limit (32766) exceeded at /home/k.sewnundun/test.pl line 16. Please find below the debug: What could be the issue? Thanks Answer This is a good sign
Dynamically-created ‘zip’ command not excluding directories properly
I’m the author of a utilty that makes compressing projects using zip a bit easier, especially when you have to compress regularly, such as for updating projects submitted to an application store (like Chrome’s Web Store). I’m attempting to make quite a few improvements, but have run into an issue, described below. A Quick Overview My utility’s command format is
Regular expression to search column in text file
I am having trouble getting a regular expression that will search for an input term in the specified column. If the term is found in that column, then it needs to output that whole line. These are my variables: the text file is in this format with a space being the field seperator, with many contact entries: I’ve tried with
Using cut to remove until a delimiter from end
I have a string with many delimiters like : abcd – efgh – foobar.extension (Delimiter ‘-‘) I want to remove the So far, I have done But this does not help as it echo’s I want to be able to keep the inital part before the final delimiter(‘-‘) is found. Answer In bash you can use this built-in string manipulation: