Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Last active November 6, 2018 15:30
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 jasdeepkhalsa/50491d0cf46c9afde7d2bfe17e56b367 to your computer and use it in GitHub Desktop.
Save jasdeepkhalsa/50491d0cf46c9afde7d2bfe17e56b367 to your computer and use it in GitHub Desktop.
Extract a value from a file of key=value pairs using BASH
#!/bin/sh
VAR=$(grep "MyVar" test | grep "^$MyVar" | cut -d'=' -f2-)
echo $VAR
something=jdiojdoijdoi
MyVar=GetHereIsAKey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment