My purpose was to print out all of name of students in a list.First of all,I created a file name "List" in /home/tuan/Desktop/Shell_programming as below
Tom
Henry
Ben
Linda
Marry
And my script "script" is
#!/bin/sh
path=/home/tuan/Desktop/Shell_programming/List
for student in $path
do
echo "$student"
done
I would strongly recommend against using unix keywords as variable names. The word "path" is used for storing locations to find programs for a user. Try typing:
echo $PATH
to see what I mean.
Yes, uppercase vs. lowercase, but just a matter of there are enough places to make mistakes in unix scripting without causing an extra headache for yourself.
Also, take a look at the following:
> cat listingnm
Tom
Henry
Ben
Linda
Marry
> cat listcontents
#! /bin/bash
filesrch=listingnm
while read student
do
echo "$student"
done < $filesrch