Thursday, January 27, 2011

Split a String in Unix

 name="TEST_THE_CODE"  
 var=$(echo $name | awk -F "THE" '{print $1 $2}')  
 set -- var  
 echo $1  
 echo $2  

 output would be  
 TEST_  
 _CODE  

No comments: