2016-11-18 90 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