How to handle a file using key,value pair in shell script

tkumaran

I have a file with below format and I want handle using key, value pair.

Format:

table name=type of load    
Sample Data:
student=full
department=delta       

Pseudo code:

for(i=0;i<arr.size;i++)      
{                   
  if key.table_name=arr[i]               
  then  
    if value. Type_of_load=full      
     then      
         process some action
    else    
    if value.type_of_load=delta     
      then     
          process some action   
    fi  
  fi  
fi  

Can anyone how to get the key and values using shell script ?

drizzt

Something like that?

while IFS== read -r key value; do
    case $key in
        delta)
            echo "key type of $value is delta"
            ;;
        full)
            echo "key type on $value is full"
            ;;
     esac
done < "$file"

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

How can we sum the values group by from file using shell script

분류에서Dev

How to add a key,value pair to a list?

분류에서Dev

Shell Script: Using files based on part of file name

분류에서Dev

Using a shell script to add a ‘</pre>’ after the last line in a large file

분류에서Dev

Check number in another file if in range using shell script

분류에서Dev

read multiple values from a property file using bash shell script

분류에서Dev

Using find in shell script

분류에서Dev

how to create variables from key value object pair in javascript

분류에서Dev

Using UML2 to parse a XMI file, how to handle stereotypes

분류에서Dev

Shell script: time and python into a file

분류에서Dev

Cost of file Operation in Shell Script

분류에서Dev

Script Shell Find a String in a file

분류에서Dev

executing shell command using shell script

분류에서Dev

How to supply an input value to the prompt via shell script?

분류에서Dev

Text to speech using shell script

분류에서Dev

Handle star * entry in mysql query from shell script

분류에서Dev

How to escape hyphen(-) in shell script?

분류에서Dev

How to run a shell script in background?

분류에서Dev

What is a Key-Value Pair?

분류에서Dev

Reading data from properties file in shell script

분류에서Dev

formatting a text file before mailing it in shell script

분류에서Dev

Cron Job: Redirecting shell script output to a file

분류에서Dev

Extract line from a file in shell script

분류에서Dev

Shell script problems: how to parse a special "word" out of a line of xml file

분류에서Dev

Shell script problems: how to parse a special "word" out of a line of xml file

분류에서Dev

How to handle variable in Batch script nested loop?

분류에서Dev

Run shell script on windows using Cygwin

분류에서Dev

Live output of shell script using `watch` in browser?

분류에서Dev

Create new files in Shell script using VIM

Related 관련 기사

  1. 1

    How can we sum the values group by from file using shell script

  2. 2

    How to add a key,value pair to a list?

  3. 3

    Shell Script: Using files based on part of file name

  4. 4

    Using a shell script to add a ‘</pre>’ after the last line in a large file

  5. 5

    Check number in another file if in range using shell script

  6. 6

    read multiple values from a property file using bash shell script

  7. 7

    Using find in shell script

  8. 8

    how to create variables from key value object pair in javascript

  9. 9

    Using UML2 to parse a XMI file, how to handle stereotypes

  10. 10

    Shell script: time and python into a file

  11. 11

    Cost of file Operation in Shell Script

  12. 12

    Script Shell Find a String in a file

  13. 13

    executing shell command using shell script

  14. 14

    How to supply an input value to the prompt via shell script?

  15. 15

    Text to speech using shell script

  16. 16

    Handle star * entry in mysql query from shell script

  17. 17

    How to escape hyphen(-) in shell script?

  18. 18

    How to run a shell script in background?

  19. 19

    What is a Key-Value Pair?

  20. 20

    Reading data from properties file in shell script

  21. 21

    formatting a text file before mailing it in shell script

  22. 22

    Cron Job: Redirecting shell script output to a file

  23. 23

    Extract line from a file in shell script

  24. 24

    Shell script problems: how to parse a special "word" out of a line of xml file

  25. 25

    Shell script problems: how to parse a special "word" out of a line of xml file

  26. 26

    How to handle variable in Batch script nested loop?

  27. 27

    Run shell script on windows using Cygwin

  28. 28

    Live output of shell script using `watch` in browser?

  29. 29

    Create new files in Shell script using VIM

뜨겁다태그

보관