The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-22-2008
prassu prassu is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 6
Substring not working if more than 1 space

I have a string which is something like this..

abcd efghijkl

when I use this using substring() function 2 spaces are bein considered as one starngely.

Is there any thing I am doing wroing

the input file maintest has the string specified and the code is below


while read lines
do
echo $lines | awk '{print substr($0,4,3)}'

done < maintest

the output is
d e

where as it should be 'd ' d followed by 2 blank spaces.

Please suggest
thanks