How to test for a specific file size


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to test for a specific file size
# 1  
Old 02-20-2006
How to test for a specific file size

Hello,

In my shell program, I need to test for a specific size of a text file before it can be imported into an oracle table.

If the size is less than that number, my program should stop processing. What is the correct command to do this test?


Thanks!
# 2  
Old 02-20-2006
to get the file size

file_size=`ls -l <path_to_file>| awk '{ print $5 }'`

then do an if

if [ $file_size -lt <size> ]
then
exit
fi
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Files test How to recover a specific variable

Hi everyone !;) I'm Arnaud and I'm new on this forum, I begin in the Shell. Let me explain, I want to test the presence of file, so far so good. Below, my code : if && && ; then Pgsql ; else echo \nLe fichier $fichier n\'existe pas ; I would like to recover in a... (16 Replies)
Discussion started by: Arnaudh78
16 Replies

2. HP-UX

How to view specific file size in HP UX?

Dear, Can anyone inform me the command to view specific file size in megabyte in hp-ux? (2 Replies)
Discussion started by: makauser
2 Replies

3. UNIX for Dummies Questions & Answers

look for file size greater than "0" of specific pattern and move those to another directory

Hi , i have some files of specific pattern ...i need to look for files which are having size greater than zero and move those files to another directory.. Ex... abc_0702, abc_0709, abc_782 abc_1234 ...etc need to find out which is having the size >0 and move those to target directory..... (7 Replies)
Discussion started by: dssyadav
7 Replies

4. Shell Programming and Scripting

Search a test file for specific words

I have the need to search a text file from my unix script to determine if it contains the strings of: 'ERROR' and/or 'WARNING'. By using Grep I can search the file and return a where one of these strings exists. Like this: cat myfile.txt | grep ERROR Output: PROCESS ERROR HERE ... (3 Replies)
Discussion started by: buechler66
3 Replies

5. UNIX for Dummies Questions & Answers

Print folder size ordered by pattern value of specific file type :-) ! challenge !

Hello dear unix command line friends ! I'm looking for a simple combinaison of ls & awk (maybe grep) to print: list of folders of a directory |_ ordered by size like what I have with $ du -sk ./* | sort -rn printing that result: 8651520 ./New Virtual Machine_1 8389120 ./Redhat ... (1 Reply)
Discussion started by: holister
1 Replies

6. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

7. AIX

Creat a File with a Specific Size

Hi everybody, Is there a command that can create a new file with a specific size? Thanks in advance. (3 Replies)
Discussion started by: aldowsary
3 Replies

8. Shell Programming and Scripting

Find the size of a single specific file

As I'm a newbie to UNIX, very newbie in fact, could anyone humour me and tell me how I'd find just the file size in bytes for a specific file? Or at least just the specific line from the ls -a for the file - call it file1 I know this sounds bad but I don't seem to be getting very far at this... (3 Replies)
Discussion started by: nortypig
3 Replies

9. Shell Programming and Scripting

how to test for file existence using file size?

ok im doing this in a normal shell. i need to check the file in the script. how should i write the if else statment? if the filesize contains 0kb then it will echo out file contains nothing else if the script contains more than 0kb then it will echo out file exist. any one care to help?... (3 Replies)
Discussion started by: forevercalz
3 Replies

10. Shell Programming and Scripting

Test to see if a drive is mounted at a specific point

I have a script that backs up our storage drive daily to one external drive and weekly to another. What I'd like to do is find a way, in the script, to test whether the drives are mounted so that it doesn't accidentally fill up the main drive in the event of a drive failure, etc. Any ideas on how... (1 Reply)
Discussion started by: spectre_240sx
1 Replies
Login or Register to Ask a Question