LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-10-2011, 04:08 AM   #1
sukhwinder
LQ Newbie
 
Registered: Mar 2011
Posts: 2

Rep: Reputation: 0
please tell me ..


How do i take a single line of input from the user in a shell script?
 
Old 03-10-2011, 04:12 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
In Bash, you can use "read", e.g.

echo "Enter a sentence: "
read sentence

echo $sentence

You'll probably want to look at the Advanced Bash-Scripting Guide at some point.

Edit: also, please use descriptive thread titles in future (i.e. ones that say something about your question/problem), like you're told to do when posting threads.

Last edited by Nylex; 03-10-2011 at 04:14 AM.
 
Old 03-10-2011, 05:30 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 03-10-2011, 05:54 AM   #4
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
For quick help on read, enter:
Code:
help read
on the command line.

More extensive help is in the man pages for bash & bash-builtins. If you are reading the man page from the CLI (i.e. using less), search for "read \[". OTOH, if you are reading the man page in Konqueror, search for "read [".

Comments
The full bash man page is almost 3400 lines. If you are serious about working in the CLI, I recommend reading it & re-reading it, although perhaps not in one sitting.

The bash-builtins man page is "only" 912 lines & covers just the 59 built in commands.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



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

All times are GMT -5. The time now is 05:54 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