Question:
Read the csv file and print the respective filed column by using the input filed separator.
Answer:
#!/usr/bin/bash
path="/home/kalam/names_and_employ_id.csv"
while IFS="," read name id
do
echo "Employee name is: $name"
echo "Employee id is: $id"
done < $path
output:
kalam@DESKTOP-OSJTLNE:~$ sh field_reading.sh
Employee name is: Name
Employee id is: id
Employee name is: raju
Employee id is: 1010
Employee name is: Naga
Employee id is: 1011
Employee name is: Naresh
Employee id is: 101
gvim names_and_employ_id.csv
Name,id
raju,1010
Naga,1011
Naresh,101
Note:
IFS Input Filed Separator in the *.csv filenames and employee id's are separated with ,
No comments:
Post a Comment