Help needed reading the file

I am reading a pipe delimted file having the 4 columns. The file content looks like

APT|string|Application ID For App|value
for env in `cat $ConfigFile`
do

        name=`echo $env | cut -d '|' -f1` 
        type=`echo $env | cut -d '|' -f2 
        prompt=`echo $env | cut -d '|' -f3`
        vval=`echo $env | cut -d '|' -f4` 
done

But for prompt the output is coming as "Application". I need the output as "Application ID For App" for prompt variable.
Please help.

Thanks,
Chandu123

Hi, use echo "$env"

Alternatively try:

while IFS="|" read name type prompt vval
do
  echo " Do stuff with $name, $type, $prompt and $vval"
done < infile

that's a useless use of cat and dangerous use of backticks. You only get the first part because the shell splits on spaces.

The shell can handle this all natively instead of running sixteen separate external processes per line, which will be hundreds of times faster.

while IFS="|" read A B C D
do
        echo "Field 1 is $A"
...
done <inputfile

Hi,

I do agree with the Coroan688. But this is how I am receiving the output when I tried above code.

while ENV="|" read name type prompt vval
do
  echo " Do stuff with $name, $type, $prompt and $vval"
done < tmp.txt
exit

Do stuff with APT|string|Application, ID, For and App|value

Please help.

Not ENV="|", but IFS="|"

IFS is de internal field separators variable.

Thanks..It worked....