Bash array pipe

Programming languages, Coding, executables, and scripting.
Post Reply
Message
Author
Tuxytux
Posts: 2
Joined: 2016-11-04 17:08

Bash array pipe

#1 Post by Tuxytux »

Hey there !

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

But P seems to get filled with blank spaces. echo "${array[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

User avatar
debiman
Posts: 3064
Joined: 2013-03-12 07:18

Re: Bash array pipe

#2 Post by debiman »

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).

Tuxytux
Posts: 2
Joined: 2016-11-04 17:08

Re: Bash array pipe

#3 Post by Tuxytux »

You are right. I dont need the grep, i assumed i did in the back of my mind(new to bash). Thanks! :wink:

Post Reply