Bash – How to output only given chars

bash

How can I crop unneeded chars, and only output what I need? For example:

input:

    ASDFQWER

output:

    DFQ

I mean in this case I need only the 3.-4.-5. chars of the string. How do I do that?

Best Answer

Use

echo "${string:index:length}" 

for your example

x="ASDFQWER"
echo "${x:2:3}"
Related Question