string - Bash extract after substring and before substring -
say have string:
random text before authentication_token = 'pywastsemjrmqwjyczpz', gravatar_hash = 'd74a97f   i want shell command extract after "authentication_token = '" , before next '.
so basically, want return pywastsemjrmqwjyczpz.
how do this?
use parameter expansion:
#!/bin/bash text="random text before authentication_token = 'pywastsemjrmqwjyczpz', gravatar_hash = 'd74a97f" token=${text##* authentication_token = \'}   # remove left part. token=${token%%\'*}                          # remove right part. echo "$token"   note works if random text contains authentication token = '...'.
Comments
Post a Comment