LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-18-2012, 04:46 PM   #1
tuts73
LQ Newbie
 
Registered: Apr 2012
Posts: 7

Rep: Reputation: Disabled
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
 
Old 04-18-2012, 05:00 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
remove the dollar sign from your read statement.

Code:
#!/bin/bash
echo "What is your username?"
read username
echo $username
 
1 members found this post helpful.
Old 04-19-2012, 02:07 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

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


Reply

Tags
bash, variable



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Variables szahmad1 Linux - Software 6 03-27-2010 09:06 AM
Bash Script: parse active process stderr, strip, dump into variables, use variables TimeFade Programming 1 02-13-2010 06:09 AM
Threads synchronisation problem (mutex variables and contitional variables) zahadumy Programming 6 12-07-2005 12:30 PM
variables jpostma Linux - General 4 05-07-2004 12:26 PM
Shel scripting: variables pointing to variables and case Dark_Helmet Programming 5 06-08-2003 11:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration