The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 08-29-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
The read command splits the line into fields separated by white space by default. You can change this by redefining the inter-field separator (IFS). Try this:


Code:
#!/bin/ksh
while IFS="" read line
do
len=`echo "$line" | wc -c`
echo $len
done


Last edited by Annihilannic; 08-29-2008 at 02:54 AM.. Reason: D'oh, too slow. :-)