Article 4ZVGE [SOLVED] not getting desired output while using 'while read'

[SOLVED] not getting desired output while using 'while read'

by
spalisetty
from LinuxQuestions.org on (#4ZVGE)
Hello,
I am trying to use 'while read' to move or redirect the contents of one file to another.
Code:ubuntu@ip-172-31-92-85:~/suman$ cat whileread.sh
#! /bin/bash
cat sleep.sh | while read files
do
echo $files
done
sleepout=$sleep.sh
echo "$sleepout"The output I am getting is like
Code:ubuntu@ip-172-31-92-85:~/suman$ ./whileread.sh
#! /bin/bash
n=1
while [ $n -le 10 ]
do
echo $n
sleep 1
n=$(($n+1))
done
.shCode:ubuntu@ip-172-31-92-85:~/suman$ cat sleep.sh
#! /bin/bash
n=1
while [ $n -le 10 ]
do
echo $n
sleep 1
n=$(($n+1))
done
ubuntu@ip-172-31-92-85:~/suman$I don't why .sh is part of the output for ./whileread. Please help.latest?d=yIl2AUoC8zA latest?i=144ojA-mkzA:p1YYXiJGR0s:F7zBnMy latest?i=144ojA-mkzA:p1YYXiJGR0s:V_sGLiP latest?d=qj6IDK7rITs latest?i=144ojA-mkzA:p1YYXiJGR0s:gIN9vFw144ojA-mkzA
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments