Ask Your Question

bash command question [closed]

asked 2016-07-20 08:34:16 -0500

sigurdsk gravatar image

Hi! Simple question, what is the bash command to see if a file exists?

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by davidva
close date 2016-07-20 17:48:16.468444

2 Answers

Sort by ยป oldest newest most voted

answered 2016-07-20 09:07:48 -0500

updated 2016-07-20 09:09:05 -0500

Interpreting your question as strictly as possible, and assuming you are writing a script wherein you would like to perform this test, the bash built-in "test" command is what you need. You can use square brackets to invoke this command for more standard-looking conditional syntax as follows:

if [ -e /path/to/file ]; then

That's equivalent, syntactically, with:

if test -e /path/to/file; then

Just FYI.

But for questions which are this simple, you should be able to consult the bash manual page (man bash from within bash) and find your own answers.

edit flag offensive delete link more


Ok, thanks man!

sigurdsk gravatar imagesigurdsk ( 2016-07-20 10:09:22 -0500 )edit

answered 2016-07-20 08:44:29 -0500

Gcroom gravatar image

You could try whereis 'name of file or keyword of file title's. It shows you where the files are that have a certain word in their name.

edit flag offensive delete link more


Checking the man page for whereis, it only works for commands.

sideburns gravatar imagesideburns ( 2016-07-20 13:55:06 -0500 )edit

your right, my bad. thank you for the correction!

Gcroom gravatar imageGcroom ( 2016-07-23 00:30:37 -0500 )edit

Question Tools

1 follower


Asked: 2016-07-20 08:34:16 -0500

Seen: 63 times

Last updated: Jul 20 '16