I want to check if a directory named "name" exists in the current working directory. is it possible to do this with ls?
ls -l | grep ^-d
shows only directories, but how to specify?
early
Do not parse the output of ls . If you are using bash try this
if [ -d "$DIRECTORY" ]; then # will enter here if $DIRECTORY exists. fi
This is the -d test. Just:
-d
if [ -d "name" ]; then echo "yay!" else echo "nay!" fi
test -d 'name' && echo "It is there"
test -d 'name' can be used in if statements, etc.
test -d 'name'
Try it?
ls -l | grep ^d name
Source: https://habr.com/ru/post/1479002/More articles:Reverse lookup after ajax call - jqueryCreate stateless client forms with server models? - pythonExpert Advice Needed to Develop a Windows C # Service That Will Use / Create Many Threads - multithreadingfixed point implementation of bool isnan (...) function in C ++ - c ++Check if the point is inside the custom mesh geometry - three.jsSitecore - handle 500 errors separately for each site in a multilevel setup - sitecoreSQLAlchemy with single table inheritance exception error - pythonFinding the actual width of the user control - c #Disable a button if the text field is empty - c #A few ablations in xyplot - rAll Articles