Skip to content

Instantly share code, notes, and snippets.

@fennb
Created August 4, 2011 01:05
Show Gist options
  • Save fennb/1124285 to your computer and use it in GitHub Desktop.
Save fennb/1124285 to your computer and use it in GitHub Desktop.
Bash string manipulation example
#!/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