title: Removing blank spaces in specific column in pipe delimited file in AIX
body: <p>Good morning. Long time reader, first time emailer so please be gentle.</p>
  
  <p>I'm working on AIX 5.3 and have a 42 column pipe delimited file. There are telephone numbers in columns 15 &amp; 16 (land|mobile) which may or may not contain spaces depending on who has keyed in the data.</p>
  
  <p>I need to remove these space from columns 15 &amp; 16 only ie</p>
  
  <pre><code>Column 15   |   Column 16 **Currently**
  01942 665432|07865346122
  01942756423 |07855 333567
  Column 15   |   Column 16 **Needs to be**
  01942665432|07865346122
  01942756423|07855333567
  </code></pre>
  
  <p>I have a quick &amp; dirty script which unfortunately is proving to be anything but quick because it's a while loop reading every single line, cutting the field on the pipe delimiter, assigning it to a variable, using sed on column 15 &amp; 16 only to strip blank spaces then writing it out to a new file ie</p>
  
  <pre><code>cat $file | while read 
  
  output
  
  do
  
  .....
  
  fourteen=$( echo $output | cut -d'|' -f14 )
  
  fifteen=$( echo $output | cut -d'|' -f15 | sed 's/ //g' )
  
  echo ".....$fourteen|$fifteen..." &gt; $new_file
  
  done
  </code></pre>
  
  <p>I know there must be a better way to do this, probably using AWK, but am open to any kind of suggestion anyone can offer as the script as it stands is taking half an hour plus to process 176,000 records.</p>
  
  <p>Thanks in advance.</p>