无法删除 psql 的页脚导致 shell 脚本

unable to remove footer for psql ressult in shell script

我有一个 psql 命令,我可以在其中获得结果,但我无法删除页脚 我的命令

sshpass -p 'password' ssh mptios@xx.xx.xxx.xxx  "PGPASSWORD=xxxxx psql -a -h 11.11.111.11 -d TGM_bb_les -U bi_it -t -c \"select count(1) from dwpub.td_bank \" "

我对上述命令的结果:-

select count(1) from dwpub.td_bank
    29

但我需要输出为

29

我试过这个命令,但仍然无法获得预期的输出

sshpass -p 'password' ssh mptios@xx.xx.xxx.xxx  "PGPASSWORD=xxxxx psql -a -h 11.11.111.11 -d TGM_bb_les -U bi_it --pset\"footer=off\" -c \"select count(1) from dwpub.td_bank \" "

谁能帮我解决这个问题

尝试使用命令:

sshpass -p 'password' ssh mptios@xx.xx.xxx.xxx  "PGPASSWORD=xxxxx psql -a -h 11.11.111.11 -d TGM_bb_les -U bi_it -t -c \"select count(1) from dwpub.td_bank \" "|tail -1

这将只显示最后一行

使用 grep 或 egrep 仅匹配数字。

sshpass -p 'password' ssh mptios@xx.xx.xxx.xxx  "PGPASSWORD=xxxxx psql -a -h 11.11.111.11 -d TGM_bb_les -U bi_it --pset\"footer=off\" -c \"select count(1) from dwpub.td_bank \" " | grep -Eo '[0-9]+$'