I had a working script which could store in a var a single string without carriage returns or spaces or tabulations of a multi-line file: the git config file.
But it no longer works as github has changed that file's syntax.
What the file currently looks like :
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:user/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
#commented line
What I'm currently using to extract the desired string :
var3=$(sed 's/^[ \t]*//' .git/config | sed ':a;N;$!ba;s/\n//g' | sed -rn 's/.*https:\/\/(.*?)fetch.*/\1/p')
echo "this is repo"
echo $var3
What I want it to return :
"this is repo"
"[email protected]:user/repo.git"
What I get :
"this is repo"
""
https, so it won't find anything. code isn't usable so far as I can tell with bash. :this regex is notbashit issed, so the shell should make little or no difference (bashdoes support regular expressions, but you are not using them here).