Home » Infrastructure » Unix » Check if file exist using schell scripting
Check if file exist using schell scripting [message #526534] Tue, 11 October 2011 08:51 Go to next message
dhivyaenjoy
Messages: 49
Registered: June 2011
Member
Hi,

I have a requirement to write a schell script where I should check existence of the file "aaa.csv" in a directory.

It should be like if the file exist it should echo "file exist" else "file do not exist"

The file is a csv file

Please do the needful

Regards,
Dhivya
Re: Check if file exist using schell scripting [message #526554 is a reply to message #526534] Tue, 11 October 2011 09:39 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator

magvivek@atana# [ -f nOall.lst ] && echo "file exist" || echo "file do not exist"
file do not exist
magvivek@atana# [ -f all.lst ] && echo "file exist" || echo "file do not exist"
file exist
Re: Check if file exist using schell scripting [message #526567 is a reply to message #526554] Tue, 11 October 2011 10:18 Go to previous messageGo to next message
dhivyaenjoy
Messages: 49
Registered: June 2011
Member
Mahesh Rajendran wrote on Tue, 11 October 2011 21:39

magvivek@atana# [ -f nOall.lst ] && echo "file exist" || echo "file do not exist"
file do not exist
magvivek@atana# [ -f all.lst ] && echo "file exist" || echo "file do not exist"
file exist


Hi Mahesh,

Thanks that worked out.

But now a little modification i would require to implement in this.

Instead of echo i need to execute one shell script if the file exist like below

[ -f nOall.lst ] && ./rr.sh || echo "file do not exist"

Thanks in advance

Awaiting for the response
Dhivya

Re: Check if file exist using schell scripting [message #526574 is a reply to message #526567] Tue, 11 October 2011 11:13 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
This question bears no real connection with Oracle.
Please find a more appropriate forum.
The topic is locked.
If I'm wrong, please, PM me (or report this message to a moderator, explain why you think it should be unlocked and it might be done).

Regards
Michel
Previous Topic: shell script in Solaris
Next Topic: INODE(HELP!!!)
Goto Forum:
  


Current Time: Sat Nov 23 20:14:30 CST 2024