1

inputfile.txt:

load1: apples,oranges
load2: vegetables,fruits

Pythoncode:

d = {}
with open('inputfile.txt') as f:
    for line in f:
        if ":" not in line:
            continue
        key, value = line.strip().split(":", 1)
        d[key] = value

In above python code, I will read input file and send values to key and value.

Then i will make use of this in program.

As I need to write script in shell, Is there any similar method in Linux shell scripting. Please help to achieve this in linux shell.

or any other method is also fine as long as i can able achieve above

I am using sh shell in linux

Bittu
  • 31
  • 2
  • 9

0 Answers0