Solved

Getting the size of a file

Posted on 2007-04-04
3
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

630 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