Correct way to use Linux commands in bash script
问题 What is the best and most correct way to use Linux commands in bash scripts in terms of path to it? Is that correct to use only ip addr show , relying on shell path, or should I find a path to the command first (like with whereis ip or command -v ip ), assign the output to some variable and then use that? 回答1: Personally, I just rely on the PATH and invoke "bare" commands. If you don't trust the user's PATH, you can reset it to a minimal default: PATH=$(/usr/bin/getconf PATH) grep "$pattern"