Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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