Bash script, returns awk: can't open file ~/.ssh/config

谁说我不能喝 提交于 2020-01-07 02:49:15

问题


I'm able to awk this file directly from the command line but when I try to use it from my script it breaks. Not sure why. Heres my script

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

回答1:


In quotes bash does not expand ~. I suggest to use $HOME:

ssh_config_path="$HOME/.ssh/config"


来源:https://stackoverflow.com/questions/40685676/bash-script-returns-awk-cant-open-file-ssh-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!