Skip to content

Instantly share code, notes, and snippets.

@halleshubham
Created September 3, 2018 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halleshubham/8b010196d5b03e08db88d10d50e26d6c to your computer and use it in GitHub Desktop.
Save halleshubham/8b010196d5b03e08db88d10d50e26d6c to your computer and use it in GitHub Desktop.
BASH: from lines of output of BASH command, parse host and port number.
#!/bin/bash
while IFS= read -r line;
do
URL=$(echo $line | grep / | cut -d/ -f3)
HOST=$(echo $URL | grep : | cut -d: -f1)
PORT=$(echo $URL | grep : | cut -d: -f2)
# TO DO
done < <( cat <file.format> | grep <substring> )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment