Bash array pipe

Need help with C, C++, perl, python, etc?

Bash array pipe

Postby Tuxytux » 2016-11-04 17:25

Hey there !

I am trying to do this
P=`echo "${array[i][j]}" | grep $somevalue`
echo $P

But P seems to get filled with blank spaces. echo "${array[i][j]}" alone works fine but piping it to grep doesnt work it seems. Is there a better way of doing this?

Appreciate any help.
Ara
Tuxytux
 
Posts: 2
Joined: 2016-11-04 17:08

Re: Bash array pipe

Postby debiman » 2016-11-04 18:28

please show us fully working examples.
please use code tags:
Code: Select all
 code goes here
to display code.

what are you trying to achieve? it seems convoluted (grep will return the whole line anyway).
it could most probably be achieved with pure bash (grep is an external utility, and every pipe '|' opens a new shell, try to avoid that).
User avatar
debiman
 
Posts: 974
Joined: 2013-03-12 07:18

Re: Bash array pipe

Postby Tuxytux » 2016-11-04 19:23

You are right. I dont need the grep, i assumed i did in the back of my mind(new to bash). Thanks! :wink:
Tuxytux
 
Posts: 2
Joined: 2016-11-04 17:08


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable