Computing.Net > Forums > Unix > how to identify the size of a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to identify the size of a file

Reply to Message Icon

Name: trichyselva
Date: August 10, 2006 at 09:00:32 Pacific
OS: xp
CPU/Ram: p4
Product: pentium
Comment:

i want to know the size of a file and check whether it is empty or not dynamically (through another script) how to write code for it



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: August 10, 2006 at 15:12:38 Pacific
Reply:

Check out the test command:

#!/bin/ksh

myfile="somefile.txt"
if [[ -s "$myfile" ]]
then
echo "$myfile exists and is greater than 0"
fi


0

Response Number 2
Name: ghostdog
Date: August 10, 2006 at 19:26:55 Pacific
Reply:

you can use
wc -c <filename> . It will give the size of the file in bytes.


0

Response Number 3
Name: trichyselva
Date: August 10, 2006 at 21:14:54 Pacific
Reply:

alert:

i agree with ur code, it checks if the file is present or not ok how to check if the file is empty or not, even if it is empty or not the file may be present, let me know if i am wrong


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: how to identify the size of a file

update the contents of a file in Un www.computing.net/answers/unix/update-the-contents-of-a-file-in-un/5963.html

how to find complete path of a file www.computing.net/answers/unix/how-to-find-complete-path-of-a-file/8177.html

To read the value of a variable www.computing.net/answers/unix/to-read-the-value-of-a-variable/5570.html