I have a data file, the content is as follows:department: customer service  section: Adepartment: marketing         section: Adepartment: finance           section: AWhen I read each line, I would extract the department name using cut command. Unfortunately, the program will automatically trim all redundant space and thus I cut the department name incorrectly.cat dept.dat | while read linedo    echo $line    echo $line | cut -c 12-29donee.g. the original line is:department: marketing         section: AWhile the program treats this line as:department: marketing section: AHow can I read the line without trimming all the redundant space?
Unix: how to read line's original content from file
echo;cut;trim
You are losing the spaces when you expand $line. Put double quotes around your variable expansion and you'll preserve the spaces:$ cat dept.dat | while read line> do>     echo $line>     echo $line | cut -c 12-29> donedepartment: customer service  section: A customer service department: marketing         section: A marketing        department: finance           section: A finance          