How to retrieve the first n characters of a variable in Bash? [duplicate] February 9, 2023 by Tarik If the variable is: FOO="qwertzuiopasdfghjklyxcvbnm" then echo ${FOO:0:10} will give the first 10 characters.