我正在编写一个 bash 脚本来查找不存在的文件,然后创建它并将其附加到它:
Host localhost
ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)
所以"line then new line 'tab' then text"
我认为它是一种敏感的格式。我知道你可以这样做:
cat temp.txt >> data.txt
Run Code Online (Sandbox Code Playgroud)
但它看起来很奇怪,因为它有两行。有没有办法以这种格式附加它:
echo "hello" >> greetings.txt
Run Code Online (Sandbox Code Playgroud) 目前,我期待在建立一个流浪我的Mac机器上的环境,这样我就可以运行vagrant up
,然后将安装rbenv
和ruby
所有我需要的。然后我有一个 Bash 脚本,它将从 github 获取我所有的 repos。
唯一的问题是我的新 vagrant vm 现在必须生成一个 ssh 密钥,然后将其链接到我的 Github 帐户。这可能很麻烦。特别是因为我想与所有有权访问我们的 repos 的人共享我的 Vagrant 文件,以便他们也可以这样做。
所以我想我可以尝试将我的主机 ssh 转发到 VM,以便 VM 可以将我的主机 ssh 转发到 Github。在这篇文章:Githubs 演练之后,我设置了我的主机 ssh 配置:
Host localhost
ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)
并设置在我的流浪文件中
Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
...
end
Run Code Online (Sandbox Code Playgroud)
当我登录到我的 VM 并运行以下命令时,我收到此错误:
$ ssh -T git@github.com`
Permission denied (publickey)
Run Code Online (Sandbox Code Playgroud)
有没有人尝试过类似的设置?VM 是一个精确的 64 位框。
编辑:
env
:
vagrant@precise64:~$ env
TERM=xterm-256color
SHELL=/bin/bash
SSH_CLIENT=10.0.2.2 53068 22
SSH_TTY=/dev/pts/0
LC_ALL=en_US …
Run Code Online (Sandbox Code Playgroud) 我正在编写我的第一个 bash 脚本。我正在让它安装我在 GitHub 上的所有存储库。
warpInLocations=("git@github.com:acc/toolkit.git" "git@github.com:acc/sms.git" "git@github.com:acc/boogle.git" "git@github.com:acc/cairo.git")
Run Code Online (Sandbox Code Playgroud)
当我安装它们时,它们就是它们。
echo "warping in toolkit, sms, boogle and cairo"
for repo in "${warpInLocations[@]}"
do
warpInDir=$(echo ${warpToLocation}${repo} | cut -d'.' -f1)
if [ -d "$warpToLocation"]; then
echo "somethings in the way.. $warpInDir all ready exists"
else
git clone $repo $warpInDir
fi
done
Run Code Online (Sandbox Code Playgroud)
此处的这一行,我希望它为我提供一个名为toolkit
or的文件夹sms
,因此在位置扭曲之后/
和之前.
,但它正在选择git@github
。我猜,因为它在.
.
我怎样才能让它在回购中选择名称?