elwayisgod
MIS
I have a script that needs to ask user where the data file is and what the data file name is and then ask what fields to show. There are only 3 fields, but I can't figure out how to allow it to put in multiple fields. I can get it to work where it asks for 1, but if I need it to know that 1,3 is field 1 and field 3, side by side. I'm stumped. Here's my code so far. I know there are more than one argument that can be passed in, but all my examples only have one and I'm stuck. This is how I try, but it will not work.
#!/usr/bin/ksh
echo "Enter the path to the data file: \n"
read pname
echo "Enter the file name of the data file: \n"
read flname
answer=y
while [ "$answer" = "y" ]
do
echo "Enter a field number that you wish to display: \n"
read fldnum
echo "Do you want to display another field? (y/n) \c"
read anymore
case $anymore in
y*|Y*) answer=y ;;
n*|N*) answer=n ;;
*) answer=y ;;
esac
cut -f$fldnum data.hw4
#!/usr/bin/ksh
echo "Enter the path to the data file: \n"
read pname
echo "Enter the file name of the data file: \n"
read flname
answer=y
while [ "$answer" = "y" ]
do
echo "Enter a field number that you wish to display: \n"
read fldnum
echo "Do you want to display another field? (y/n) \c"
read anymore
case $anymore in
y*|Y*) answer=y ;;
n*|N*) answer=n ;;
*) answer=y ;;
esac
cut -f$fldnum data.hw4