Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to sed regexp #514

Open
dxcSithLord opened this issue Mar 3, 2024 · 0 comments
Open

Alternative to sed regexp #514

dxcSithLord opened this issue Mar 3, 2024 · 0 comments

Comments

@dxcSithLord
Copy link

dxcSithLord commented Mar 3, 2024

Not a bug, but have you considered, for readability,

curl -sL "https://api.github.com/repos/wagoodman/dive/releases/latest" | \
     grep '"tag_name":' | \
     awk -F'"' '{print $(NF-1)}'

with awk instead of using sed? The awk statement uses quote (") as the field separator, making the version one less than the NF (number of fields)
Consider, also using "<RETURN>" to wrap the lines so they can be seen more easily. The "" must be followed by return and be the last character on the line (in case you did not know).

dive/README.md

Lines 100 to 115 in 925cdd8

DIVE_VERSION=$(curl -sL "https://api.github.com/repos/wagoodman/dive/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
curl -OL https://github.com/wagoodman/dive/releases/download/v${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.deb
sudo apt install ./dive_${DIVE_VERSION}_linux_amd64.deb
```
Using snap:
```bash
sudo snap install docker
sudo snap install dive
sudo snap connect dive:docker-executables docker:docker-executables
sudo snap connect dive:docker-daemon docker:docker-daemon
```
**RHEL/Centos**
```bash
DIVE_VERSION=$(curl -sL "https://api.github.com/repos/wagoodman/dive/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')

Just a suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant