0

1.how do I substitute a variable output within another command .I want to use the date and portfolio values within each grpc call. I also want to print the output of the grpc call and also store it in a variable for further processing.

2.I get json like result back, is there a way to pretty print it in bash?

Quite new to bash scripting.

portfolios="1739719,1714630"
IFS=',' read -ra PIDS <<< "$portfolio"
MYDATE=$(date -d '09/04/2020 00:00:00' +"%s")
echo $MYDATE
for i in "${PIDS[@]}"; do
    mycall=$(grpc_cli call trades:10443 com.mycom.Service.GetByPortfolioId 'source_system:CONTR portfolio_id:$PID as_of: {seconds: $MYDATE nanos: 000000000}')
    echo $mycall    
done
serah
  • 2,057
  • 7
  • 36
  • 56

1 Answers1

0
  1. Variables are only resolved in strings starting with " instead of ': "source_system:CONTR portfolio_id:$i as_of: {seconds: $MYDATE nanos: 000000000}"
  2. How can I pretty-print JSON in a shell script?
Šimon Kocúrek
  • 1,591
  • 1
  • 12
  • 22
  • tat did not work - mycall=$(grpc_cli call trades:10443 mercuria.tradestore.model.TradeService.GetDealsByPortfolioId "source_system:ENDUR portfolio_id:$PID as_of: {seconds: $mydate nanos: 000000000}") echo $mycall – serah Apr 10 '20 at 07:30