Sponsored Content
Top Forums Shell Programming and Scripting Moving files based on size (string to integer) Post 302788349 by Flakman on Monday 1st of April 2013 03:23:10 PM
Old 04-01-2013
Moving files based on size (string to integer)

I have a log file that I want to archive out as it reaches 100MB. I am using the following to get the file size into a variable but get the error "line 5: [: -gr: binary operator expected"
This is still the test code to work out the comparison.

Code:
filesize=$(wc -c < logfile.log)
if [ $filesize -gr 100000000 ]
then
  echo "is greater than 100M"
else
  echo "is less than 100M"
fi

I'm sure there's something I'm being braindead on and overlooking. I'm pretty adept at batch files, but this is my initial foray into bash.

Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Moving files till the size is less than 200000.

Hi, I need your help. Suppose I have a directory called /home/rooh This directory contains files and directories. For ex drwxr-xr-x 3 rooha arboradm 96 Apr 6 03:24 batches drwxr-xr-x 2 rooha arboradm 96 Apr 6 03:21 worker -rw-rw-rw- 1 rooha arboradm ... (1 Reply)
Discussion started by: rooh
1 Replies

2. Shell Programming and Scripting

Moving the files based on count and time.

Hi, I have a requirement ,let us say 1000 files needs to be transferred in an hour from one path to another path and if the files (1000 files) are transferred within an hour ( say 40 mins), then the process should remain idle for the remaining time ( 20 mins). (3 Replies)
Discussion started by: Asaikarthik
3 Replies

3. Shell Programming and Scripting

Compare two files based on integer part only

Please see how can I do this: File A (three columns): X1,Y1,1.01 X2,Y2,2.02 X3,Y3,4.03 File B (three columns): X1,Y1,1 X2,Y2,2 X3,Y3,4.0005 Now I have to compare file A and B based on the integer part of column 3. Means first 2 rows should be OK and the third row should not satisfy... (12 Replies)
Discussion started by: yale_work
12 Replies

4. Shell Programming and Scripting

Moving a file based on size

hello, I am creating a script that is going to scan the contents of a directory, and if it finds a certain DocumentName that is a certain size (The example, DocumentName and a size of 8777) If this file exists, it needs to be moved to a directory for later removal/processing..anyone have... (7 Replies)
Discussion started by: jeffs42885
7 Replies

5. UNIX for Dummies Questions & Answers

moving files based on condition

hi i have to move files and send an email and attached the bad files to inform the developer about that. #!/bin/ksh BASE_DIR=/data/SrcFiles cd $BASE_DIR ## finding the files from work directory which are changed in 1 day find -type f -name "*.csv" –ctime 0 > /home/mydir/flist.txt ##... (14 Replies)
Discussion started by: awais290
14 Replies

6. UNIX for Advanced & Expert Users

Moving multiple files based on the pattern

I want to search for a particular file name patterns and move them to a specific folder, is it possible to do it with awk or sed? (1 Reply)
Discussion started by: rudoraj
1 Replies

7. UNIX for Dummies Questions & Answers

Script moving files based on date

Hi, I need a script that moves files based on date to a folder. The folder should be created based on file date. Example is : Date file name ----- -------- Oct 08 07:39 10112012_073952.xls Oct 09 07:39 10112012_073952.xls Oct 10 07:39 ... (6 Replies)
Discussion started by: rockingvj
6 Replies

8. Shell Programming and Scripting

Moving files based on file name

Hi All, I have multiple files in the folder, I want to move those files into the other folder on based of name File names: Template_server1_01==> Template_server1_02==>To one directory /Server1 Template_server1_03==> Template_server2_01==> Template_server2_02==>To one... (9 Replies)
Discussion started by: sharsour
9 Replies

9. Shell Programming and Scripting

Moving old files based on pattern

Hi all I am trying to loop through a directory of files using a given search pattern. some of the files will be duplicated due to the pattern, but of the duplicate files i wanted to move the older files to another location. Is there any straightforward way of doing this ? One of ways I... (1 Reply)
Discussion started by: sthapa
1 Replies

10. UNIX for Beginners Questions & Answers

Replace integer string in a variable based on month?

Hi Folks - Linux Version = Linux 2.6.39-400.128.17.el5uek x86_64 I have a process that determines the start and end load periods for an Oracle data load process. The variables used are as follows follows: They are populated like such: However, the load requires the month to be the... (11 Replies)
Discussion started by: SIMMS7400
11 Replies
vxtranslog(1M)															    vxtranslog(1M)

NAME
vxtranslog - administer transaction logging SYNOPSIS
vxtranslog [-H] [-l] [-m {on|off}] [-n number] [-q {on|off}] [-s size] DESCRIPTION
The vxtranslog command is used to administer transaction logging in Veritas Volume Manager (VxVM). This feature can be used to record transactions that are carried out by the vxconfigd daemon at the request of VxVM commands, and can be used in conjunction with the command logging feature (see vxcmdlog(1M)). When the current log file reaches a maximum size, it is renamed as a historic log file, and a new current log file is created. A limited number of historic log files is preserved to avoid filling up the file system. In addition, logging of query requests is turned off by default to prevent the log files from being filled too quickly. Each log file contains a header that records the host name, host ID, and the date and time that the log was created. See the EXAMPLES sec- tion below for a description of the entries that are recorded in a log file. OPTIONS
-H Displays detailed help about the usage of the command. -l Lists current settings for transaction logging. This shows whether transaction and query logging are enabled, the maximum number of historic log files, and the maximum log file size. -m {on|off} Turns transaction logging on or off. By default, transaction logging is turned on, but query logging is turned off. Query log- ging can be turned on by using the -q option. -n number Sets the maximum number of historic log files to maintain. The default number is 5. If number is set to no_limit, there is no limit on the number of historic log files that are created. -q {on|off} Turns query logging on or off. By default, query logging is turned off to prevent the log files filling too rapidly. -s size Sets the maximum size to which a transaction log can grow. (Note that this setting has no effect on existing historic log files.) The suffix modifiers k, m, and g may be used express sizes in kilobytes, megabytes and gigabytes respectively. If no suffix is specified, the default units are kilobytes. If size is set to no_limit, there is no limit on the size of the log file. The size of the transaction log is checked after an entry has been written so the actual size may be slightly larger than that specified. When the log reaches the specified size, the current transaction log file, translog, is renamed as the next available historic log file, translog.number, where number is an integer from 1 up to the maximum number of historic log files that is cur- rently defined. If the maximum number of historic log files has been reached, the oldest historic log file is removed, and the current log file is renamed as that file. The default maximum size of the transaction log file is 1m(1MB). EXAMPLES
Turn on query logging: vxtranslog -q on Set the maximum transaction log file size to 512KB: vxtranslog -s 512k Set the maximum number of historic transaction log files to 10: vxtranslog -n 10 The following are sample entries from a transaction log file: Thu Feb 13 19:30:57 2003 Clid = 26924, PID = 3001, Part = 0, Status = 0, Abort Reason = 0 DA_GET SENA0_1 DISK_GET_ATTRS SENA0_1 DISK_DISK_OP SENA0_1 8 DEVNO_GET SENA0_1 DANAME_GET 0x1d801d8 0x1d801a0 GET_ARRAYNAME SENA 50800200000e78b8 CTLR_PTOLNAME /pci@1f,4000/pci@5/SUNW,qlc@4/fp@0,0 GET_ARRAYNAME SENA 50800200000e78b8 CTLR_PTOLNAME /pci@1f,4000/pci@5/SUNW,qlc@5/fp@0,0 DISCONNECT <no request data> The first line of each log entry is the time stamp of the transaction. The Clid field corresponds to the client ID for the connection that the command opened to vxconfigd. The Status and Abort Reason fields contain error codes if the transaction does not complete normally. The remainder of the record shows the data that was used in processing the transaction. Note: The client ID is the same as that recorded for the corresponding command in the command log. FILES
/etc/vx/log Symbolic link to the log directory. This can be redefined if necessary. /etc/vx/log/translog Current transaction log. /etc/vx/log/translog.number Historic transaction logs. SEE ALSO
vxcmdlog(1M) Veritas Volume Manager Troubleshooting Guide VxVM 5.0.31.1 24 Mar 2008 vxtranslog(1M)
All times are GMT -4. The time now is 05:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy