![]() ![]() GKE: upgrade Anthos Config Management for GKE cluster.GKE: show pod distribution across nodes and zones.Ansible: generating templates with deep directory structure using with_filetree.Ansible: adding custom apt repository with ‘signed-by’ gpg key.GCP: Cloud Run/Function to handle requests to GKE cluster during maintenance.Kubernetes: using a delete patch with kustomize.GCP: deploying a Python WSGI Gunicorn app on Cloud Run.GCP: Cloud Run with build trigger coming from remote GitHub repository.GKE: terraform lifecycle ‘ignore_changes’ to manage external changes to GKE cluster.GCP: determining whether GKE cluster mode is Standard or Autopilot.Bash: testing if a file exists, has content, and is recently modified.GCP: determining whether ASM is installed via asmcli or gcloud fleet.GitLab: generating URL that can be used for Merge Request from fork to upstream.Bash: counting number of times substring is found in directory.Terraform: fixing error “querying Cloud Storage failed: storage: bucket doesn’t exist”.Linux: Mounting a loopback ext4/xfs filesystem to isolate or enforce storage limits.Bash: Outputting text in color for readability.Ansible: regex capture groups with lineinfile to preserve yaml indentation.Bash: Fixing an ASCII text file changed with Unicode character sequences.Bash: Using BASH_REMATCH to pull capture groups from a regex.You can use brute force LookBehind if you need variable length LookBehind, but does not seem worth it when \K does a better job grep -Po "(?:(?<= /?\"])*" greptest.txt Grep -P does not support output of any capture group but first, but pcregrep can do it $ sudo apt-get install pcregrep -y # fails because LookBehind requires static string length ![]() $ grep -Po "(?)[^” as well as “”, it would be tempting to believe we could add “s?” to the end of the tag name. # use non-captured LookBehind to isolate value But even easier would be using a LookBehind that does not capture the starting tag at all. # a bit smarter, by taking characters until '[^ /my/dataįrom this imperfect parse, you might use some combination of sed/awk/cut to get to your ultimate atomic value. Using the -E extended regular expression flag you could attempt to isolate the value. In this article, I’ll show how LookBehind and LookAhead regular expression support can provide enhanced parsing abilities to your shell scripts.įor example, consider an xml file “test.xml” with the contents: Grep has support for Perl compatible regular expressions (PCRE) by using the -P flag, and this provides a number of useful features. ![]()
0 Comments
Leave a Reply. |