How to check if something is a file, directory or other?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check if something is a file, directory or other?
# 1  
Old 03-15-2012
How to check if something is a file, directory or other?

I want to know how you would go about checking if something is either a file or a directory. mostly for argument validation stuff.

I know -d is to see if its a directory but im guessing -f is for files??
# 2  
Old 03-15-2012
Check your man page for test.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Check that at least one file exists in the directory.

There are some files with suffix dates like abc_20032019.dat abc_17032019.dat If at least one file exists then perform some operation else exit from execution. Korn shell ---------------------------------- array=($inputdir/abc*.dat) If ] ] then echo " file exits" else echo " file does... (10 Replies)
Discussion started by: Rajesh123
10 Replies

2. Shell Programming and Scripting

Check for file with a particular extension in a particular directory

Hi, I have a directory which I am passing in my script as a parameter. Parameter name has been set to $TCH_FILE_DIRECTORY. I want to know if there's atleast 1 (or more) files in this directory with the extension '.tch'. How can I find this using ksh. (4 Replies)
Discussion started by: Bhavesh Sharma
4 Replies

3. Shell Programming and Scripting

Check whether file exists in directory

Hi guys, I am beginner trying to learn unix. So any help is welcomed. My requirement is to check whether is a file exists in a particular directory or not. The directory path and filename are taken dynamically with user interaction. So the program should continue only if the $filename... (1 Reply)
Discussion started by: maris_markur
1 Replies

4. Shell Programming and Scripting

How to check if the file exists in directory?

Hi Gurus, I have a requests to find if all the file in the filelist exist in certain directory. example: my filelist abc def ddd cde afg how can I find these 5 files exists at director /home/abc Thanks in advance (7 Replies)
Discussion started by: ken6503
7 Replies

5. Shell Programming and Scripting

check if a given string is a file or directory

hi i want to know how to do this if the given is /tmp/ and it is a valid directory then it will echo directory if the given is /tmp/file.txt and is a valid file then it will echo file.. thanks! (5 Replies)
Discussion started by: h0ujun
5 Replies

6. Shell Programming and Scripting

How to check if a file exists in a directory?

I want to perform SQL *Loader operation only if a file named "load.txt" exists in a directory "/home/loc/etc". Please help how to check this with a if condition. (8 Replies)
Discussion started by: vel4ever
8 Replies

7. Shell Programming and Scripting

how to check file exist in a directory or not

HI folks, can any one tell me how to check whether the file is existed in a directory or not . let me tell you my requirement : if the file is existed i should display a one message or else i have to send a mail .. i have the mail logic .. but I'm failed to check file existence .. please... (5 Replies)
Discussion started by: sravan008
5 Replies

8. Shell Programming and Scripting

check if directory and file exists

cp $PATHLOGS/$DATE/*.* $TMP/logs_tmp/ cp $PATHLOGS/$DATE1/*.* $TMP/logs_tmp/ Before copying the files I have to check if the directory $DATE1 and $DATE2 exists. If directory exists then, check if the folder contains some files. if the file exists then, check if the file size is greater... (3 Replies)
Discussion started by: sandy1028
3 Replies

9. Programming

how to check if directory/file exist using c/c++

Hi there, how to check if directory/file exist using c/c++ under linux/unix. Thanks. Steven (2 Replies)
Discussion started by: steven88
2 Replies

10. Shell Programming and Scripting

how to check if directory/file exist using c/c++

Hi there,, how to check if directory/file exist using c/c++ under unix/linux? I can use access() under Window MFC. Thanks. Steven (1 Reply)
Discussion started by: steven88
1 Replies
Login or Register to Ask a Question