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

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -