Re: [GENERAL] multiple sql results to shell

Поиск
Список
Период
Сортировка
От Randy Strauss
Тема Re: [GENERAL] multiple sql results to shell
Дата
Msg-id 49FB3234-4E2C-474E-ABA3-E2C9196E59AE@stanford.edu
обсуждение исходный текст
Ответ на [GENERAL] multiple sql results to shell  (Mark Lybarger <mlybarger@gmail.com>)
Список pgsql-general
On Oct 23, 2017, at 08:37, pgsql-general-owner@postgresql.org wrote:

psql ..... | while read a; do
#    some code
done

The only problem I find with this is that you can't pass variables out
of the while loop,

To get input from a file w/o a sub-shell,
you can put the input at the end of the loop:

====
#!/bin/sh                                                                                                                                                                                                                                     

cat > file <<EOF                                                                                                                                                                                                                              
ab                                                                                                                                                                                                                                            
cd                                                                                                                                                                                                                                            
ef                                                                                                                                                                                                                                            
EOF                                                                                                                                                                                                                                           
while read a; do
    b="$b $a"
    echo $b
done < file
====
-Randy

В списке pgsql-general по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: [GENERAL] using conda environment for plpython3u?
Следующее
От: Paul Jungwirth
Дата:
Сообщение: [GENERAL] Two versions of an extension in the same cluster?