hi
i have a requirement to input a string to a shell script and to split the string to multiple fields,
the string is copied from a row of three columns (name,age,address) in an excel sheet.
the three columns (from excel) are seperated with a tab when pasted in the command prompt, but when the
string is assigned to a variable, the tab disappears to a space.
code is given below
echo "Enter the string : \c"
read line
name=`echo $line | awk -F"\t" '{print $1}'`
age=`echo $line | awk -F"\t" '{print $2}'`
address=`echo $line | awk -F"\t" '{print $3}'`
output
+ echo Enter the string : \c
Enter the string : + read line
john teth 45 1st cross, stmark road
+ + echo john teth 45 1st cross, stmark road
+ awk -F\t {print $1}
name=john teth 45 1st cross, stmark road
+ + echo john teth 45 1st cross, stmark road
+ awk -F\t {print $2}
age=
+ + echo john teth 45 1st cross, stmark road
+ awk -F\t {print $3}
address=
i would like to get
name=john teth
age=45
address=1st cross, stmark road
can any one guide me ...