2016-11-18 58 views
0

我可以直接从命令行awk该文件,但是当我尝试从脚本中使用它时,它会中断。不知道为什么。我的脚本Bash脚本,返回awk:无法打开文件〜/ .ssh/config

#!/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 
+0

你从哪里使用'$ username'命令? – Cyrus

+0

还没有使用过它 –

回答

1

在引号bash不扩展~。我建议使用$HOME

ssh_config_path="$HOME/.ssh/config" 
+1

或者只是略去引号。 – Barmar