Here is a simple script which reads and display each word of the file separated by a blank space whose path is entered by
the user. The IFS(Internal File Separator) of the file is blank space in other case it should be changed accordingly.
echo -n "Enter the path to file whose content is to be read line by line : "
#ask user to enter the path of the file whose data is to be read word by word
read file_path
#input the path
for i in `cat $file_path`
#start the loop
do
echo $i
#display each word of file separated by blank space
done
#terminate the loop
Note: The above script can be executed by giving it execute permission as follows:
#chmod +x Script_Name
#./Script_Name
OR
Directly executing the script as follows:
#bash Script_name
#sh Script_Name
0 comments:
Post a Comment