Solved

Getting the size of a file

Posted on 2007-04-04
3
220 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reinstall 1 96
how to check for shares on aix 1 112
Linux : adding the new user with password option, 11 132
Problem logging tar errors 11 74
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

734 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