- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script to check for a file with csv extension
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2010 04:24 AM
07-19-2010 04:24 AM
script to check for a file with csv extension
Thanks
F.R.
- Tags:
- ls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2010 04:38 AM
07-19-2010 04:38 AM
Re: script to check for a file with csv extension
Simply do something like this:
# cd /path
# ls *.csv > /dev/null 2>&1|| mailx -s "No CVS files present!" nandinho@some.net < /dev/null
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2010 04:51 AM
07-19-2010 04:51 AM
Re: script to check for a file with csv extension
files=$(ls /tmp/*.csv > /dev/null | wc -l)
if [ "$files" != "0" ]
But its not working..
F.R.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2010 05:28 AM
07-19-2010 05:28 AM
Re: script to check for a file with csv extension
> My idea was to have a script like this:
files=$(ls /tmp/*.csv > /dev/null | wc -l)
And this yields a value of ZERO when there *are* files since you throw away any STDOUT.
Look again at what I suggested. It leverages the return code of the 'ls' to ascertain whether or not there were files.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2010 09:24 AM
07-20-2010 09:24 AM
Re: script to check for a file with csv extension
do
if [ -f $file ]
then
command to process file
else
mail -s "File does not exist" name@domain.tld < /tmp/nofile.msg
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2010 07:23 PM
07-20-2010 07:23 PM
Re: script to check for a file with csv extension
>if [ -f $file ]
There is no need for this check since the previous ls(1) would return nothing and skip the loop.
You may want to redirect stderr:
for file in $(ls *csv 2> /dev/null ); do