Analyze lists using bash scrip

In Progress

I Need a bash script that does the following:

step 1: parse

You are given 2 lists of strings.

In the first list each entry has the following format:

@protocol protocolName

we will define a hashmap

var protocolToSuperProtocols = new hashmap<string, set>

protocolToSuperProtocols should contain all protocolNames as keys, and a list of implementedProtocol as the values.

* Ignore any trailing spaces

* if an implementedProtocol appears more than once, add it only one


@protocol p1

@protocol p2

@protocol p4

will output:

protocolToSuperProtocols='([p1]="p2,p3" , [p2]="", [p4]="p5" )'

The second list contains the following entries:

@interface className : superClass

the entries must have className but superClass and implementedProtocol list are optional.

lets define two hashMaps:

var classToSuperClass = new hashmap

var classToProtocols = new hashmap<string, set>

classToSuperClass will contain className as key and superClass as value

* if a class does not have a superclass, ignore the entry

* a class will have only one superclass

* ignore spaces

classToProtocols will contain className as key and the list of implementedProtocol as value

* if a class has implementedProtocol it will always have a super class

* if a class does not have implementedProtocol list, leave blank

* if a value repeats itself in implementedProtocol list, add it only once

* ignore spaces


@interface A : B

@interface B : C

@interface D

@interface C : D

will output:

classToSuperClass ='([A]="B" , [B]="C", [C]="D", [D]="" )'

classToProtocols ='([A]="" , [B]="p1,p2,p3", [C]="p1,p4", [D]="" )'

step 2: processing

we will define our result datastructure:

var protocolToImps = new hashmap<string, set >

do the following:

for (classToSuperClass as (className => superClass)) {



echo protocolToImps;

function travereOverClassHierarchAndAct(className) {

if (className == null) return;

implementingProtocols = classToProtocols[className];

addBindToResultList(className, implementingProtocols);

superClass = classToSuperClass[className];



function addBindToResultList(classname, protocolList) {

if (protocolList == null) return;

for (implementingProtocols as protocol) {

protocolToImps[protocol] += className;

addBindToResult(className, protocolToSuperProtocols[protocol] );



the following should output (for the above dataset):

protocolToImps ='([p1]="A,B,C",[p2]="A,B,C",[p3]="A,B,C",[p4]="A,B,C",[p5]="A,B,C")'

*Please not that == null means empty list or undefined key

*There should be not circular dependencies in the data set

*Please use bash 4 with associative arrays and test for bash script version in the beginning of the script

Skills: Mac OS, Shell Script

See more: string processing in c, define data entry, datastructure, shell bash, example shell script, bash 0, p4, bash script, bash script data, circular list example, string processing, echo script, output using, trailing step, script bash, parse using, bash shell, shell script string value, analyze test, macos shell script, bash using sed example, script bash processing list, parse string bash script, bash parse string, bash shell script format

Project ID: #4256753

Awarded to:


Bash programmer.

$40 USD in 2 days
(6 Reviews)

5 freelancers are bidding on average $50 for this job


Hi there, i am very interested to complete this project. please see my past reviews lets complete this project

$50 USD in 3 days
(10 Reviews)

Ready to discuss further

$80 USD in 3 days
(3 Reviews)

Hi! Please, read a private message! Thanks!

$30 USD in 0 days
(2 Reviews)

I've been using bash scripts in my work extensively for the past 6 years, so this project shouldn't be any problem. However I will need additional clarifications, because it is not clear to me in the examples you pr More

$50 USD in 3 days
(0 Reviews)