How do I get an one liner for this condition?
if [ -f ~/.ssh/config ]
then
echo -e "\xE2\x9C\x94 Config file existing"
fi
My attempt:
if [ ! -f ~/.ssh/config ] || echo -e "\xE2\x9C\x94 Config file existing"
How do I get an one liner for this condition?
if [ -f ~/.ssh/config ]
then
echo -e "\xE2\x9C\x94 Config file existing"
fi
My attempt:
if [ ! -f ~/.ssh/config ] || echo -e "\xE2\x9C\x94 Config file existing"
Try this,
if [ -f ~/.ssh/config ]; then echo -e "\xE2\x9C\x94 Config file existing"; fi
or
[ ! -f ~/.ssh/config ] || echo -e "\xE2\x9C\x94 Config file existing"
or
[ -f ~/.ssh/config ] && echo -e "\xE2\x9C\x94 Config file existing"
and the else has to come last
[ -f ~/.ssh/config ] && echo -e "\xE2\x9C\x94 Config file existing" || echo -e "\xE2\x9E\x97 No config file"
The most readable way (IMHO) is to use the test utility explicitly:
test -f ~/.ssh/config && echo -e "\xE2\x9C\x94 Config file existing"