Parse CSV in bash and assign variables

后端 未结 3 1241
耶瑟儿~
耶瑟儿~ 2021-01-03 07:39

I have a csv of the format (Working on Bash on linux)

DN , MAC , Partition ,  

123 , abc , xyz  
321 , asd , asd 

I am able to parse it u

3条回答
  •  遥遥无期
    2021-01-03 07:56

    you can also try this

    file1 stores all the DN for which you want to retrieve the information

    #parse.awk
    
    BEGIN { FS="," ; OFS= "\t"}
    
    FNR==NR{ a[$1]; next }
    
    $1 in a { print $1,$2,$3}
    

    call awk -f parse.awk file1 csvfile.csv

提交回复
热议问题