03-13-2002
testing for file size in script
Has anyone got a few tips on how I can test if the file size is 0?
I am moving files on a regular basis from one location to another with ftp. The files which are 0 bytes in size we want to discard.
Thankyou in advance.
10 More Discussions You Might Find Interesting
1. AIX
How do you test a variable size to know if it is empty or not?
Thanks (4 Replies)
Discussion started by: jango
4 Replies
2. Shell Programming and Scripting
Hi,
I want to use an 'if statement' that will check if a certian file is greater in size than a certain value given by the user, but cannot get it to work. Do you have any ideas how this can be done?
Your help is appreciated! (6 Replies)
Discussion started by: Dado
6 Replies
3. UNIX for Dummies Questions & Answers
Hi, I am trying to write a script that will send an email to me if the size of a folder is below a certain amount.
Does anyone know how to write the if (size < 1000) statement. I know how to send the email? I just need the code for determing a folder size.
Thanks,
Eric (5 Replies)
Discussion started by: ejbrever
5 Replies
4. Shell Programming and Scripting
Hi guys,
firstly I'm working on SunOS 5.10 Generic_125100-10 sun4u sparc SUNW,Sun-Fire-V240
I've made a script to compress two directory and then send them to an other server via ftp. This is working very well.
Inside theis script I decide to log usefull data for troubleshooting in case of... (7 Replies)
Discussion started by: moustik
7 Replies
5. Shell Programming and Scripting
Hi All,
I have some requirement. i dont know if we can write some shell script to fulfill the requirement. Here is my requirement...
I have some files under /var/opt/abc/xyz like below.
-rw-r--r-- 1 root root 789222 Aug 14 11:03 big.sh
-rw-r--r-- 1 root root 789222 Aug 14 11:03 big.txt... (25 Replies)
Discussion started by: s_linux
25 Replies
6. Shell Programming and Scripting
Hi Experts,
I have a script like
$ORACLE_HOME/bin/sqlplus username/password # << ENDSQL
set pagesize 0 trim on feedback off verify off echo off newp none timing off
set serveroutput on
set heading off
spool Schemaerrtmp.txt
select ' TIMESTAMP COMPUTER NAME ... (5 Replies)
Discussion started by: welldone
5 Replies
7. Shell Programming and Scripting
Hi
can some one please help me how i can get the output i require:
My text file "sample.txt" contains the text like below
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_fedora-lv_root
15G 2.6G 12G 19% /hari
Filesystem Size ... (3 Replies)
Discussion started by: harimhkr
3 Replies
8. Shell Programming and Scripting
I need to split a file if it is over 2GB in size (or any size), preferably split on the lines. I have figured out how to get the file size using awk, and I can split the file based on the number of lines (which I got with wc -l) but I can't figure out how to connect them together in the script.
... (6 Replies)
Discussion started by: ssemple2000
6 Replies
9. UNIX for Dummies Questions & Answers
noted down (44 Replies)
Discussion started by: mirwasim
44 Replies
10. Shell Programming and Scripting
I have a bash script. I need a modification for safety.
my original bash script:
mv /home/script/backup /home/script/backup2
mysql -u user -ppassword -Ddatabase --batch --skip-column-names -e 'select id, url from videos where url like "%http%" limit 1' |
while read id url
do youtube-dl... (1 Reply)
Discussion started by: tara123
1 Replies
LEARN ABOUT CENTOS
fstrim
FSTRIM(8) System Administration FSTRIM(8)
NAME
fstrim - discard unused blocks on a mounted filesystem
SYNOPSIS
fstrim [-o offset] [-l length] [-m minimum-free-extent] [-v] mountpoint
DESCRIPTION
fstrim is used on a mounted filesystem to discard (or "trim") blocks which are not in use by the filesystem. This is useful for solid-
state drives (SSDs) and thinly-provisioned storage.
By default, fstrim will discard all unused blocks in the filesystem. Options may be used to modify this behavior based on range or size,
as explained below.
The mountpoint argument is the pathname of the directory where the filesystem is mounted.
OPTIONS
The offset, length, and minimum-free-extent arguments may be followed by the multiplicative suffixes KiB=1024, MiB=1024*1024, and so on for
GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes KB=1000, MB=1000*1000, and
so on for GB, TB, PB, EB, ZB and YB.
-h, --help
Print help and exit.
-o, --offset offset
Byte offset in filesystem from which to begin searching for free blocks to discard. Default value is zero, starting at the begin-
ning of the filesystem.
-l, --length length
Number of bytes after starting point to search for free blocks to discard. If the specified value extends past the end of the
filesystem, fstrim will stop at the filesystem size boundary. Default value extends to the end of the filesystem.
-m, --minimum minimum-free-extent
Minimum contiguous free range to discard, in bytes. (This value is internally rounded up to a multiple of the filesystem block
size). Free ranges smaller than this will be ignored. By increasing this value, the fstrim operation will complete more quickly
for filesystems with badly fragmented freespace, although not all blocks will be discarded. Default value is zero, discard every
free block.
-v, --verbose
Verbose execution. When specified fstrim will output the number of bytes passed from the filesystem down the block stack to the
device for potential discard. This number is a maximum discard amount from the storage device's perspective, because FITRIM ioctl
called repeated will keep sending the same sectors for discard repeatedly.
fstrim will report the same potential discard bytes each time, but only sectors which had been written to between the discards would
actually be discarded by the storage device. Further, the kernel block layer reserves the right to adjust the discard ranges to fit
raid stripe geometry, non-trim capable devices in a LVM setup, etc. These reductions would not be reflected in fstrim_range.len
(the --length option).
AUTHOR
Lukas Czerner <lczerner@redhat.com>
Karel Zak <kzak@redhat.com>
SEE ALSO
mount(8)
AVAILABILITY
The fstrim command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
util-linux November 2010 FSTRIM(8)