0

我可以直接从命令行 awk 这个文件,但是当我尝试从我的脚本中使用它时它会中断。不知道为什么。这是我的脚本

#!/bin/bash

ssh_config_path="~/.ssh/config"

echo -n "Enter the username of the account you'd like to switch to > "
read username


awk '
  !x{x=sub(/github-secondary/,"github.com")}
  !y{y=sub(/github\.com/,"github-secondary")}
  1' $ssh_config_path
4

1 回答 1

1

引号中的 bash 不展开~。我建议使用$HOME

ssh_config_path="$HOME/.ssh/config"
于 2016-11-18T20:48:51.203 回答