LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-25-2008, 03:48 AM   #1
junust
Member
 
Registered: Jul 2008
Location: Israel Ramat Gan
Distribution: CentOs 5.3, SuSe 11.1, Solaris 9, Slackware 13
Posts: 81

Rep: Reputation: 15
bash script, empty (enter button pushing only) value catching


Hi All

Have to catch "enter button pushing only" value

i.e

#!/bin/bash
read something


So if to push enter button whithout any parrameter on this script, what is retun value of "$something" is?

seems to be not the same empty value like " " parameter i.e
$something == " " dos't work

I have to chech in this script, when user just push "enter button" whiout any parameter in READ command execution

Thx

Last edited by junust; 12-25-2008 at 03:49 AM.
 
Old 12-25-2008, 04:06 AM   #2
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
Code:
#!/usr/bin/env bash

read -p "Enter something: " SOMETHING

if [ "$SOMETHING" == '' ]
then
    echo "\$SOMETHING is empty"
else
    echo $SOMETHING
fi
 
Old 12-25-2008, 04:18 AM   #3
junust
Member
 
Registered: Jul 2008
Location: Israel Ramat Gan
Distribution: CentOs 5.3, SuSe 11.1, Solaris 9, Slackware 13
Posts: 81

Original Poster
Rep: Reputation: 15
work like a charm !!!

Did't know about ' ' empty expression


Thanks!
 
  


Reply



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
How to have mouse button act as "enter" key in bash xmrkite Linux - Software 7 10-17-2006 05:51 PM
BASH: cannot enter special-named dir from script Roger Krowiak Programming 3 08-24-2006 06:19 AM
Is there any way to turn off the computer power without pushing the button? Necronomicom Slackware 11 02-27-2006 03:50 AM
Bash Script test for empty dir uopjohnson Linux - Software 3 10-07-2005 06:45 PM
Testing for enter in bash script bwysocki Programming 8 06-16-2005 09:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:11 AM.

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