![조건이 하나의 안감인 경우[중복]](https://linux55.com/image/105249/%EC%A1%B0%EA%B1%B4%EC%9D%B4%20%ED%95%98%EB%82%98%EC%9D%98%20%EC%95%88%EA%B0%90%EC%9D%B8%20%EA%B2%BD%EC%9A%B0%5B%EC%A4%91%EB%B3%B5%5D.png)
이 상황에 대해 단일 라이너를 어떻게 구합니까?
if [ -f ~/.ssh/config ]
then
echo -e "\xE2\x9C\x94 Config file existing"
fi
내 시도:
if [ ! -f ~/.ssh/config ] || echo -e "\xE2\x9C\x94 Config file existing"
답변1
이 시도,
if [ -f ~/.ssh/config ]; then echo -e "\xE2\x9C\x94 Config file existing"; fi
또는
[ ! -f ~/.ssh/config ] || echo -e "\xE2\x9C\x94 Config file existing"
또는
[ -f ~/.ssh/config ] && echo -e "\xE2\x9C\x94 Config file existing"
else
마지막에 배치 해야 함
[ -f ~/.ssh/config ] && echo -e "\xE2\x9C\x94 Config file existing" || echo -e "\xE2\x9E\x97 No config file"
답변2
가장 읽기 쉬운 방법(IMHO)은 test
유틸리티를 명시적으로 사용하는 것입니다.
test -f ~/.ssh/config && echo -e "\xE2\x9C\x94 Config file existing"