[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with changing FS
From: |
Scott McNeilly |
Subject: |
Problem with changing FS |
Date: |
Wed, 12 Sep 2007 11:40:25 -0400 |
Here are two scripts, one uses awk on tru64 Unix 5.1b, and the other uses
gawk on the same computer.
The first one, using awk as supplied with the tru64 OS, works. The second,
using gawk 3.1.5, doesn't work as expected.
Here is first one, with output:
echo 'Hi'
line='dyn~11-SEP-07~isir_load_date'
echo 'line=' $line
var=`echo $line | awk '{{ FS = "~"} { print $2}}'`
echo 'var=' $var
lab=`echo $line | awk '{{ FS = "~"} { print $3}}'`
echo 'lab=' $lab
if [ "$var" = "" ]; then
echo 'variable has no value'
else
echo $var
fi
Hi
line= dyn~11-SEP-07~isir_load_date
var= 11-SEP-07
lab= isir_load_date
11-SEP-07
Here is second one, with output. It appears that the change to the FS
variable fails, that is, the assignment of "~" to FS fails.
echo 'Hi'
line='dyn~11-SEP-07~isir_load_date'
echo 'line=' $line
var=`echo $line | gawk '{{ FS = "~"} { print $2}}'`
echo 'var=' $var
lab=`echo $line | gawk '{{ FS = "~"} { print $3}}'`
echo 'lab=' $lab
if [ "$var" = "" ]; then
echo 'variable has no value'
else
echo $var
fi
Hi
line= dyn~11-SEP-07~isir_load_date
var=
lab=
variable has no value
Scott McNeilly
Information Technology
Community College of Rhode Island
400 East Avenue
Warwick, RI 02886
401-825-2005
- Problem with changing FS,
Scott McNeilly <=