Skip to content
Advertisement

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

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

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:

Advertisement