Escaping quotes in bash (Embedded awk)

前端 未结 3 2069
北海茫月
北海茫月 2021-01-16 13:50

I have a complex command I am passing via ssh to a remote server. I am trying to unzip a file and then change its naming structure and extension in a second ssh command. T

3条回答
  •  悲哀的现实
    2021-01-16 14:01

    You need to escape the " to prevent them from closing your quoted string early, and you need to escape the $ in the awk script to prevent local parameter expansion.

    ssh root@server1 "gzip -d /tmp/file.out-20171119.gz; echo file* | awk -F'[.-]' '{print \$1\$3\".log\"}'"
    

提交回复
热议问题