title: UNIX Comparing string with space from command output
body: <p>I have a delimited flat file and I want to find the column position of a user given header. The problem is some of my headers have spaces in them, and when I do a comparison it treats the string of two words as two arguments. My code will work if none of the delimited fields have spaces in them.   </p>
  
  <pre><code>#!/bin/bash
  # Unique Values
  #Example use: my_script file.txt '|' 'SOME VARIABLE'
  
  DELIM=$2
  VAR=$3
  HEADERS=$(sed -n 1p $1)
  COUNTER=1
  
  while [ $VAR != $(echo $HEADERS | cut -d $DELIM -f $COUNTER) ]
  do
      COUNTER=$((COUNTER+1))
  done
  echo $COUNTER
  </code></pre>