Korn shell Tutorials :Read input from user,Files

Korn shell Tutorials :Read input from user,Files
Read in a Variable
From a user we read with: read var. Then the users can type something in. One should first print something like: print -n "Enter your favorite haircolor: ";read var; print "". The -n suppresses the newline sign.
Read into a File Line for Line
To get each line of a file into a variable iteratively do:
{ while read myline;do
# process $myline
done } < filename
To catch the output of a pipeline each line at a time in a variable use:
last |sort
{
while read myline;do
# commands
done }

No comments:

 
Top Blogs