如何在执行 vertica 查询时在 shell 脚本中打印错误?
how to print error in shell script while executing a vertica query?
我想打印赋值变量中的错误
#!/bin/bash
a=$(vertica copy query) # if i got error here
echo $a
你需要用2>&1
重定向stderr
到stdout
,然后如果命令有错误你会得到错误:
#!/bin/bash
a=$(vertica copy query 2>&1) # if i got error here
echo $a
我想打印赋值变量中的错误
#!/bin/bash
a=$(vertica copy query) # if i got error here
echo $a
你需要用2>&1
重定向stderr
到stdout
,然后如果命令有错误你会得到错误:
#!/bin/bash
a=$(vertica copy query 2>&1) # if i got error here
echo $a