Skip to content

Instantly share code, notes, and snippets.

@pierrefevrier
Created May 19, 2017 12:27
Show Gist options
  • Save pierrefevrier/a349f13267c8f54e2bb71c8bd577770a to your computer and use it in GitHub Desktop.
Save pierrefevrier/a349f13267c8f54e2bb71c8bd577770a to your computer and use it in GitHub Desktop.
Cut usefull samples
# ===================================================================
# EXTRACT PARTS OF A STRING
# ===================================================================
typeset -r STRING='1.0.0-just-a-test'
# GET THE FIRST PART ONLY (=1.0.0)
echo "$STRING" | cut -d '-' -f1
# GET THE LAST PART ONLY (=just-a-test)
echo "$STRING" | cut -d '-' -f2-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment