Jump to content

Getting input from user

- - - - -

  • Please log in to reply
3 replies to this topic

#1
restin84

restin84

    Learning Programmer

  • Members
  • PipPipPip
  • 53 posts
I have an assignment to write a script which requires the user to input four lines of text. Those four lines of text will be manipulated in various ways. Is there a way to save these for lines of text before I save them in a file? Should I use the "read" command?

#2
visionviper

visionviper

    Newbie

  • Members
  • Pip
  • 5 posts
What language? Or are you just making a shell script?

#3
restin84

restin84

    Learning Programmer

  • Members
  • PipPipPip
  • 53 posts
Yes it is just a shell script

#4
DarkLordofthePenguins

DarkLordofthePenguins

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 409 posts
For a shell script, you should use the read command four times and save each line in a variable.


read line1;

read line2;

read line3;

read line4;


There's no need to declare or initialize the variables. read declares them implicitly.
Programming is a journey, not a destination.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users