相关疑难解决方法(0)

如何在Mac上获取GNU的readlink -f的行为?

在Linux上,该readlink实用程序接受一个-f跟随其他链接的选项.这似乎不适用于Mac和可能基于BSD的系统.相当于什么?

这是一些调试信息:

$ which readlink; readlink -f
/usr/bin/readlink
readlink: illegal option -f
usage: readlink [-n] [file ...]
Run Code Online (Sandbox Code Playgroud)

macos freebsd sh

341
推荐指数
13
解决办法
11万
查看次数

在所有子目录上运行git pull

如何在不cd进入每个repo的根目录的情况下从共享父目录更新多个git存储库?我有以下几个单独的git存储库(不是子模块):

/plugins/cms
/plugins/admin
/plugins/chart
Run Code Online (Sandbox Code Playgroud)

我想一次更新它们或者至少简化我当前的工作流程:

cd ~/plugins/admin
git pull origin master
cd ../chart
git pull
Run Code Online (Sandbox Code Playgroud)

等等

git bash

220
推荐指数
13
解决办法
9万
查看次数

如何解析shell脚本中的符号链接

给定绝对或相对路径(在类Unix系统中),我想在解析任何中间符号链接后确定目标的完整路径.奖励积分也可以同时解析〜用户名表示法.

如果目标是目录,则可以将chdir()放入目录然后调用getcwd(),但我真的想从shell脚本而不是编写C帮助程序.不幸的是,shell倾向于试图隐藏用户的符号链接(这是OS X上的bash):

$ ls -ld foo bar
drwxr-xr-x   2 greg  greg  68 Aug 11 22:36 bar
lrwxr-xr-x   1 greg  greg   3 Aug 11 22:36 foo -> bar
$ cd foo
$ pwd
/Users/greg/tmp/foo
$
Run Code Online (Sandbox Code Playgroud)

我想要的是一个函数resolve(),这样当从上例中的tmp目录执行时,解析("foo")=="/ Users/greg/tmp/bar".

bash shell scripting symlink

211
推荐指数
7
解决办法
15万
查看次数

提取目录路径和文件名

我有一个变量,其中包含目录路径以及文件名.我想从Unix目录路径中单独提取文件名并将其存储在变量中.

fspec="/exp/home1/abc.txt"  
Run Code Online (Sandbox Code Playgroud)

unix shell

36
推荐指数
3
解决办法
16万
查看次数

“路径”参数值无效:不存在文件

正如Terraform Resource: 执行 apply 时发生连接错误中所述

我将代码更改为以下内容

provisioner "remote-exec" {
    connection {
      type        = "ssh"
      host        = aws_eip.nat-eip.public_ip
      user        = "ubuntu"
      private_key = file("/id_rsa.pem")
    }
    inline = [
      "chmod +x /tmp/start_node.sh",
      "sudo sed -i -e 's/\r$//' /tmp/start_node.sh", # Remove the spurious CR characters.
      "sudo /tmp/start_node.sh",
    ]
  }
Run Code Online (Sandbox Code Playgroud)

但我仍然遇到同样的错误

Error: Invalid function argument

  on explorer.tf line 60, in resource "aws_instance" "explorer":
  60:       private_key = file("/id_rsa.pem")

Invalid value for "path" parameter: no file exists at /id_rsa.pem;

this function works only with files …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services terraform

7
推荐指数
2
解决办法
3万
查看次数

标签 统计

bash ×2

shell ×2

amazon-web-services ×1

freebsd ×1

git ×1

macos ×1

scripting ×1

sh ×1

symlink ×1

terraform ×1

unix ×1