Choose your weapon of choice:
localhost>expr substr "123456" 1 3
123
localhost>echo "123456" | cut -c1-3
123
localhost>echo "123456" | awk '{print substr($0, 1, 3)}'
123
Choose your weapon of choice:
localhost>expr substr "123456" 1 3
123
localhost>echo "123456" | cut -c1-3
123
localhost>echo "123456" | awk '{print substr($0, 1, 3)}'
123
if using bash
VAR=’123456′ ; echo ${VAR:0:3}
${variable:startposition:lenght} – substring.