Monday, July 11, 2011

Reading a file and writing to stdout shell

content of hello.dat file:

acer@ubuntu:/tmp$ cat hello.data
hello
how are you
wonderful
great awesome
May be might be
acer@ubuntu:/tmp$ 

content of script file:

acer@ubuntu:/tmp$ cat hh.sh
#!/bin/bash
while read line ;do
echo $line ;
done < /tmp/hello.data
acer@ubuntu:/tmp$
OUTPUT:

acer@ubuntu:/tmp$ ./hh.sh
hello
how are you
wonderful
great awesome
May be might be

No comments:

Post a Comment