Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Bash array pipe

Programming languages, Coding, Executables, Package Creation, 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: 3063
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