Created
January 5, 2018 01:40
-
-
Save blizzrdof77/41e9625369a79f9bb88101ff93ca9bc2 to your computer and use it in GitHub Desktop.
Bash Function: Count the number of lines in a string as variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------- | |
# 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