Search This Blog

Saturday, September 30, 2023

Shell script 7

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

What is the sanity checks you have done for STA?

 Sanity checks for STA: Linking Checks: We need to check., is there any missing modules or missing pins in a library. this is done by link c...