Skip to content

Instantly share code, notes, and snippets.

@markcastle
Created December 2, 2021 19:58
Show Gist options
  • Save markcastle/336a416170a66b5688e2510b3183108c to your computer and use it in GitHub Desktop.
Save markcastle/336a416170a66b5688e2510b3183108c to your computer and use it in GitHub Desktop.
Extract Version string from a dotnet C# project file using just grep and sed
rem Extract Version string from a dotnet C# project file using just grep and sed...
# eg source file ./ProjectFolder/ProjectName.csproj contains..
# <Version>0.0.3</Version>
grep -Eoi "<version>([[:digit:]\.]+)</version>" ./ProjectFolder/ProjectName.csproj | sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p'
# Expected Result...
0.0.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment