-1

abc_hosts,pwd_host_id,pwd_host_id,hostname,ddd_status,dddd_status,

start_hosts,,,,,,,,,,,,,,,,,,, ,1,o1,fhffhfh,1,1,fff,fdfd,172.33.33.33,172.30.30.12,172.30.30.11,oreere.dff,43,443343,1111,43435,1099,43434443444,3232321312312 end_hosts,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,

closed as unclear what you're asking by dr01, Archemar, Anthony Geoghegan, derobert, Julie Pelletier Sep 9 '16 at 8:52

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What line has the error? Also, you have a space after = for str4 – Eric Renouf Aug 15 '16 at 14:02
  • i am getting the error for below lines. "./Anitha.sh: line 19: str1: command not found ./Anitha.sh: line 21: str2: command not found ./Anitha.sh: line 23: str3: command not found ./Anitha.sh: line 24: str4: command not found" – Sangram Aug 15 '16 at 14:05
  • 1
    shellcheck.net is really helpful; it points out that you've set arr1 but are using arr_t – Jeff Schaller Aug 15 '16 at 14:08
  • 1
    You might want to pass this through shellcheck.net it'll help clean up a bunch of errors along the way – Eric Renouf Aug 15 '16 at 14:08
  • 1
    @Sangram, when you edit a post to remove all details, the details are still viewable in the edit history. If you are trying to prevent sensitive details from being publicly viewable, you shouldn't have posted them in the first place. I have flagged this question for moderator attention. Please don't vandalize your own posts. – Wildcard Sep 9 '16 at 3:23
6

First of all, you really, really, really don't want to be doing this sort of thing in bash. There are tools that are specifically designed for this type of job and bash is very much not one of them. Attempting to do any but the most basic text parsing in bash is hard, error prone, and painful to read or write. It is also very slow.

Now, your specific error (please always include the exact error you are receiving) is:

/home/terdon/scripts/foo.sh: line 24:  : command not found

So the error is on line 24. Specifically, it is the space you have after the =:

str4= "$str1 $str3 $str2"

should be

str4="$str1 $str3 $str2"

You also have the same problem on line 25:

arr_t[$m]= $str4

should be

arr_t[$m]=$str4

I suggest you ask a different question, explain what your script is trying to do and we can give you a saner approach than bashing your head against the wall like this.

  • Hi all can you check this link: unix.stackexchange.com/questions/303527/…. and can you please suggest me how to do this. – Sangram Aug 15 '16 at 16:14
  • I changed the code now it's printing like this : 1 1 eth0:0 172.16.5.45 255.255.255.0 172.16.5.1 1 1 1 2 1 1 eth0:0 eth0:1 172.16.5.45 172.16.5.46 255.255.255.0 255.255.255.0 172.16.5.1 172.16.5.1 1 1 1 1 1 2 3 1 1 1 eth0:0 eth0:1 eth0:2 172.16.5.45 172.16.5.46 172.16.5.47 255.255.255.0 255.255.255.0 255.255.255.0 172.16.5.1 172.16.5.1 172.16.5.1 1 1 1 1 1 1 How to print all in once? – Sangram Aug 15 '16 at 18:15
  • 1
    Dat bash pun though – TheLovelySausage Sep 9 '16 at 6:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.