How do I correctly use variables with sed?

I need to use a string variable in a sed command. My attempt is given in script.sh, it does not do what I want, I assume because my variable contains characters that I need sed to evaluate. I am working in linux bash. input.txt delicious.banana gross.apple script.sh adjectives="delicious\|gross\|bearable\|yummy" sed "s/\($adjectives\)\.//g" input.txt > output.txt output.txt desired… Read More How do I correctly use variables with sed?

How do I extract specific strings from multiple files and write them to .txt in bash?

I have a lot of files in the folder filesToCheck, some examples given below. I need the output result.txt as also shown below. I can use linux bash with any commands that do not require extra installations. The try-out below (with help from stackoverflow) has two problems when I execute it. It only looks for… Read More How do I extract specific strings from multiple files and write them to .txt in bash?

Recursively unzipping a folder with ZipFile/Python

I am trying to write a script which can unzip something like this: Great grandfather.zip Grandfather.zip Father.zip Child.txt What I have so far: from os import listdir import os from zipfile import ZipFile, is_zipfile #Current Directory mypath = ‘.’ def extractor(path): for file in listdir(path): if(is_zipfile(file)): print(file) with ZipFile(file,’r’) as zipObj: path = os.path.splitext(file)[0] zipObj.extractall(path)… Read More Recursively unzipping a folder with ZipFile/Python

Powershell regex group : how do I get all subgroups 2

I want to extract file1, file2 I know how to do this in javascript, I’m lost in Powershell, I can only extract the whole second match following that tut https://devblogs.microsoft.com/scripting/regular-expressions-regex-grouping-regex/, what’s the syntax ? $regex = ‘(.+\\)*(.+)\.(.+)$’ $data = @’ "C:\test\file1.txt" "C:\test\file2.txt" ‘@ [RegEx]::Matches($data,$regex).value >Solution : Here is how you could do it using the… Read More Powershell regex group : how do I get all subgroups 2

VBA Append unique regular expressions to string variable

How can I grab matching regular expressions from a string, remove the duplicates, and append them to a string variable that separates each by a comma? For example, in the string, "this is an example of the desired regular expressions: BPOI-G8J7R9, BPOI-G8J7R9 and BPOI-E5Q8D2" the desired output string would be "BPOI-G8J7R9,BPOI-E5Q8D2" I have attempted to… Read More VBA Append unique regular expressions to string variable