Created
August 4, 2011 01:05
-
-
Save fennb/1124285 to your computer and use it in GitHub Desktop.
Bash string manipulation example
This file contains hidden or 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
#!/bin/bash | |
MYSTRING="hello there" | |
STRLEN=${#MYSTRING} | |
let STARTPOS=$[STRLEN-5] | |
echo "First 5: ${MYSTRING:0:5}" | |
echo "Last 5: ${MYSTRING:$STARTPOS:5}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment