Skip to content

Instantly share code, notes, and snippets.

Avatar

SHACK halleshubham

  • Scientific Games
  • Pune
View GitHub Profile
@halleshubham
halleshubham / BASH_ParseHostNPort.sh
Created Sep 3, 2018
BASH: from lines of output of BASH command, parse host and port number.
View BASH_ParseHostNPort.sh
#!/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> )
@halleshubham
halleshubham / BASH_ParsePropertiesFile.sh
Last active Sep 3, 2018
BASH: Parse .properties file into two saperate arrays.
View BASH_ParsePropertiesFile.sh
#!/bin/bash
file=<filename.format>
declare -A valueArray
declare -a keyArray
while IFS='=' read -r key value
do
key=($(echo $key | tr '.' '_'))
@halleshubham
halleshubham / BASH_DeployExecuteScript_On_RemoteLinux.sh
Last active Sep 3, 2018
BASH: Deploy and execute script on remote Linux node
View BASH_DeployExecuteScript_On_RemoteLinux.sh
#!/bin/bash
PASSWORD=<PASSWORD>
node=<IP>
# Copy to remote node
echo y | pscp -pw "${PASSWORD}" /path/to/Script.sh <user>@"$node":/tmp/Script.sh
# Move to required / accessible directory
echo y | plink -ssh -pw "${PASSWORD}" -t <user>@"$node" "sudo cp /tmp/Script.sh /required/path/"
# Convert to Linux BASH (if file edited in Windows)
@halleshubham
halleshubham / BASH_CheckSubString.sh
Last active Sep 3, 2018
BASH script to Check for sub string
View BASH_CheckSubString.sh
#!/bin/bash
if [[ "$string" == *"$substring"* ]]; then
# TO DO
fi