我有字符串:“./ Delivery Note.doc 1”,其中:
$1 = ./Delivery
$2 = Note.doc
$3 = 1
我需要执行sum命令连接$ 1和$ 2但保留空格(./Delivery Note.doc)。我试试这个,但它修剪了空白:
| '{ command="sum -r "$1 $2"
结果:./ DeliveryNote.doc
答案 0 :(得分:1)
$ echo "./Delivery Note.doc 1" | awk '{ command="sum -r "$1" "$2; print command}'
sum -r ./Delivery Note.doc
答案 1 :(得分:1)
执行sum命令
echo "./Delivery Note.doc 1" | awk '{ command="sum -r \""$1" "$2"\""; print command}' | bash