Search This Blog

Shell Script: substring

#!/bin/bash
str=abcdef
substr=${str:0:3} 
echo $substr # abc
substr=${str:3:3}
echo $substr # def
substr=${str:1:5} 
echo $substr # bcdef

No comments:

Post a Comment