如何逃避用单引号引起的反引号?

时间:2018-06-28 22:57:22

标签: bash shell amazon-web-services amazon-ec2 aws-cli

我有这个方便的脚本来打印显示正在运行的实例的名称,类型和ID的表。

// Make sure we have a reference to the pdf API so we can getField etc.
var pdfObject = this;

// I'm assuming the day and date offset should not be hardcoded
var entries = Entry.loadAll(pdfObject, 1, "10/25/2015");

// check the entries
entries.forEach( function(entry) {
  let fits = entry.checkFit(entries);
  console.log('Slot check for entry '+entry.id+': '+fits);
});

aws ec2 describe-instances \ --filters "Name=instance-state-code,Values=16" \ --query 'Reservations[*].Instances[*].[Tags[?Key==`Name`]|[0].Value, InstanceType, InstanceId]' \ --output table

我试图将此命令作为别名/函数添加到我的zshrc中,但是我只是找不到一种方法来逃避最后一次出现在“名称”周围的背景。请注意,这种情况下反引号用单引号引起来。感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

选中此link,它说明了如何推迟变量扩展。我认为最好的方法是使用函数包装命令,并且在执行命令时将对反斜线包围的单词中的变量进行评估,而不是对其进行解释。