Skip to content

Instantly share code, notes, and snippets.

@blizzrdof77
Created January 5, 2018 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blizzrdof77/41e9625369a79f9bb88101ff93ca9bc2 to your computer and use it in GitHub Desktop.
Save blizzrdof77/41e9625369a79f9bb88101ff93ca9bc2 to your computer and use it in GitHub Desktop.
Bash Function: Count the number of lines in a string as variable
# -----------------------------------------
# count the number of lines in a string as variable
#
# @1 = string
# -----------------------------------------
function count-new-lines() {
if [ -z "$1" ]; then
echo "Must provide string as variable.."
return
else
echo "$1" | wc -l
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment