Skip to content

Instantly share code, notes, and snippets.

@justdoit0823
Created September 11, 2017 08:55
Show Gist options
  • Save justdoit0823/59093996f27d09d8d32ec6d4936a3ce1 to your computer and use it in GitHub Desktop.
Save justdoit0823/59093996f27d09d8d32ec6d4936a3ce1 to your computer and use it in GitHub Desktop.
How to manipulate string in bash.
# initialize string array
FILES=(aaa bbb ccc)
# retrive array's all elements
for file in `${FILES[@]}`
do
echo $file
done
# remove string's prefix
echo ${file#prefix}
# remove string's suffix
echo ${file%suffix}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment