Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

terminal - What is the meaning of flag -s in this command?

I have met a command to load nvm environment in .zshrc, but I don't know what it exactly does with flag -s. I know that the square bracket is condition to check whether folder in this command exists or not. But don't know what -s does.

[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm

Does anyone know the flag -s in this command? Thank in advance.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

[ is the same as test. Checking test's manpage:

-s file       True if file exists and has a size greater than zero.

Update: Actually, using man '[' works, too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.7k users

...