I wish to store the Output of the following command over my postgres database
sudo -u postgres -H -- psql -d firstdb -c"select count(col2) from table2;"
into a variable defined in shell. I saw this way somewhere-
abc=sudo -u postgres -H -- psql -d firstdb -c"select count(col2) from table2;" echo abc
but seems to be not working Is there any other way to store the output so as to apply cut query to fetch the value and check for the size of column??
You can do:
abc=$(svn://solace2/svn/vrs32/branches/feature/ipv6_support 2>&1)
and then do echo $abc
to see the output. Notice the 2>&1 at the end will redirect stderr to stdout before assigning stdout to the variable, meaning abc
will contain error messages as well as regular messages.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.