LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   variables (https://www.linuxquestions.org/questions/linux-newbie-8/variables-940536/)

tuts73 04-18-2012 04:46 PM

variables
 
Hi all, just wondering if you can help - i have a program that works but now i want to prompt for username and use the store value, but it prompts but doesnt use the variable as far as i can see....

#!/bin/bash

showMenu () {
echo "1) Display user account on the laptop"
echo "2) Display the bash history"
echo "3) Does the Mozilla Firefox history log file exist"
echo "4) quit"
}


var=username

while [ 1 ]
do
showMenu
read CHOICE
case "$CHOICE" in
"1")
cat /etc/group |cut -d: -f1
;;
"2")
cat /home/john403920394/.bash_history
;;

"3") echo "Please enter a username: "
read $username
FILE=$1/home/$username/.mozilla/firefox/b7wuc85h.default/places.sqlite

if [ -f $FILE ];
then
echo "File $FILE this file does exist."
else
echo "File $FILE does not exist."

fi

;;


"4")
exit
;;
esac
done


Would appriciate any help - thank you

Kustom42 04-18-2012 05:00 PM

remove the dollar sign from your read statement.

Code:

#!/bin/bash
echo "What is your username?"
read username
echo $username


grail 04-19-2012 02:07 AM

As demonstrated, please also use [code][/code] tags when displaying code to make it readable and keep formatting.


All times are GMT -5. The time now is 01:32 PM.