Shell : How to perform a text substring?

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

1 thought on “Shell : How to perform a text substring?

Leave a Reply

Your email address will not be published. Required fields are marked *