Solved

Getting the size of a file

Posted on 2007-04-04
3
218 Views
Last Modified: 2013-12-27
I am trying to add a line to a report if a certain file is empty. I am trying to use a if statement to do this. Does anyone know the command for getting the file size? Here is what I have:

if
    /bin/find .  -size 0c | grep ${PWD}/raw.txt
then
    /bin/echo "There are no alerts in the audit logs today"  >> ${PWD}/report_${DBSIDS}_`date +%y%m%d`.txt
else
    /bin/sed G raw.txt >> ${PWD}/report_`date +%y%m%d`.txt
0
Comment
Question by:sikyala
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
nixfreak earned 500 total points
ID: 18852341
if [ ! -s  "${PWD}/raw.txt" ] ; then
    /bin/echo "There are no alerts in the audit logs today"  >> ${PWD}/report_${DBSIDS}_`date +%y%m%d`.txt
fi
else
    /bin/sed G raw.txt >> ${PWD}/report_`date +%y%m%d`.txt
0
 
LVL 7

Expert Comment

by:nixfreak
ID: 18852386
> Does anyone know the command for getting the file size?

$ du -h file
0
 

Author Comment

by:sikyala
ID: 18852689
it worked. Thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question