Sponsored Content
Top Forums Shell Programming and Scripting Compare size of one file with other file in Linux Post 302938826 by hemantakhandare on Thursday 19th of March 2015 08:20:00 AM
Old 03-19-2015
Compare size of one file with other file in Linux

Hi,

I have 32 files for which I want to check size of each file withe other file and if size is same then some action.
Any suggestion to write such script.

Logic:
  1. have list of 32 files
  2. using loop first compare size of one file with remaining 31 ,
  3. do same iteration for each file with other .
    1. if a==b match found then compare content of files
    2. if both condition satisfies then rename first file as back and create touch file
  4. end.

Thanks

Last edited by rbatte1; 03-19-2015 at 02:23 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to compare file size after ftp?

Is possible if I want to campare file size on source and destination after ftp transfer? If anybody know, please explain to me. (1 Reply)
Discussion started by: icemania
1 Replies

2. Shell Programming and Scripting

compare file size from a output file from a script

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

3. Shell Programming and Scripting

How to compare size of two file which is in one directory

I have two file in a Directory.I want a script which will compare the Size of Two file. Can Anyone Help me on this: linasplg11:/opt/dataout/kk/linasplg11 # cat size -rwxrwxrwx 1 root root 16658 Jan 8 13:58 lina_IP_SIP_1231325621210.xml -rwxr-xr-x 1 root root 16672 Jan 8 14:30... (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies

4. Shell Programming and Scripting

to write a script to compare the file size in the current directory and previous dir

hi, i am new to this site. i want to write a script to compare the file size of the files in the current dir with the files in the previous directory. the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to... (5 Replies)
Discussion started by: tweety
5 Replies

5. What is on Your Mind?

Linux Centos 5.4 BTMP file size

Dear fellows, I have Centos 5.4 linux with DNS server, all logs are normal, in my /var/log/ btmp files is getting larger day by day. What is this btmp file for? How can i reduce the file siez or control file size. Waiting. MAZ (1 Reply)
Discussion started by: maz
1 Replies

6. Shell Programming and Scripting

Is there any way to find the compressed size of a file without compressing it in linux

i need to backup a directory from one partition to another and and compress that directory after backing up, so i need to predict the compressed size of the directory with out actually compressing it, to check whether the space is available in the destination partition to accommodate the zipped... (2 Replies)
Discussion started by: Kesavan
2 Replies

7. UNIX for Dummies Questions & Answers

PSFTP- Compare file size

Hi, I'm using PSFTP to transfer files from one machine to a virtual machine with UBUNTU OS installed on it. I'm trying to find a way to make sure the files that I'm uploading / downloading are being uploaded/ downloaded properly. I want to compare the size of the local file and the remote... (0 Replies)
Discussion started by: sessie
0 Replies

8. Shell Programming and Scripting

Script to Compare file size and delete the smaller

I am pretty new to scripting, so I appreciate your advice in advance. The problem: 100 directories each containing 2 files that have the same extension with random names. The only attribute that discriminates the files is size. I would like to write a script that compares the files for size... (6 Replies)
Discussion started by: JC_1
6 Replies

9. Linux

File size limitation in Linux

Hi friends, I tried to take a backup of my PC using tar command. But it ended with an error tar: /home/backup/back.tar.gz: Cannot write: No space left on device tar: Error is not recoverable: exiting now But i checked the disk space and there is enough space is available. ]# df Filesystem... (11 Replies)
Discussion started by: siva3492
11 Replies

10. Shell Programming and Scripting

Compare file size and then copy/overwrite

// Redhat I have this code working, but need to add one more qualification so that I don't overwrite the files. #!/bin/sh cd /P2/log/cerner_prod/millennium/archive/ for f in * do || continue #If this isn't a regular file, skip it. && continue #If a backup already... (2 Replies)
Discussion started by: Daniel Gate
2 Replies
FusionInventory::Agent::Tools(3pm)			User Contributed Perl Documentation			FusionInventory::Agent::Tools(3pm)

NAME
FusionInventory::Agent::Tools - OS-independant generic functions DESCRIPTION
This module provides some OS-independant generic functions. FUNCTIONS
getFormatedLocalTime($time) Returns a formated date from given Unix timestamp. getFormatedGmTime($time) Returns a formated date from given Unix timestamp. getFormatedDate($year, $month, $day, $hour, $min, $sec) Returns a formated date from given date elements. getCanonicalManufacturer($manufacturer) Returns a normalized manufacturer value for given one. getCanonicalSpeed($speed) Returns a normalized speed value (in Mhz) for given one. getCanonicalSize($size) Returns a normalized size value (in Mb) for given one. getSanitizedString($string) Returns the input stripped from any control character, properly encoded in UTF-8. compareVersion($major, $minor, $min_major, $min_minor) Returns true if software with given major and minor version meet minimal version requirements. getDirectoryHandle(%params) Returns an open file handle on either a command output, or a file. logger a logger object directory the directory to use getFileHandle(%params) Returns an open file handle on either a command output, a file, or a string. logger a logger object command the command to use file the file to use, as an alternative to the command string the string to use, as an alternative to the command getFirstLine(%params) Returns the first line of given command output or given file content, with end of line removed. logger a logger object command the exact command to use file the file to use, as an alternative to the command getAllLines(%params) Returns all the lines of given command output or given file content, with end of line removed. logger a logger object command the exact command to use file the file to use, as an alternative to the command getFirstMatch(%params) Returns the result of applying given pattern on the first matching line of given command output or given file content. pattern a regexp logger a logger object command the exact command to use file the file to use, as an alternative to the command getLastLine(%params) Returns the last line of given command output or given file content. logger a logger object command the exact command to use file the file to use, as an alternative to the command getLinesCount(%params) Returns the number of lines of given command output or given file content. logger a logger object command the exact command to use file the file to use, as an alternative to the command canRun($binary) Returns true if given binary can be executed. canRead($file) Returns true if given file can be read. canLoad($module) Returns true if given perl module can be loaded (and actually loads it). hex2char($value) Returns the value converted to a character if it starts with hexadecimal prefix, the unconverted value otherwise. Eg. 0x41 -> A, 41 -> 41. hex2dec($value) Returns the value converted to a decimal if it starts with hexadecimal prefix, the unconverted value otherwise. Eg. 0x41 -> 65, 41 -> 41. dec2hex($value) Returns the value converted to an hexadecimal if it doesn't start with hexadecimal prefix, the unconverted value otherwise. Eg. 65 -> 0x41, 0x41 -> 0x41. any BLOCK LIST Returns a true value if any item in LIST meets the criterion given through BLOCK. all BLOCK LIST Returns a true value if all items in LIST meet the criterion given through BLOCK. none BLOCK LIST Returns a true value if no item in LIST meets the criterion given through BLOCK. uniq BLOCK LIST Returns a new list by stripping duplicate values in LIST. file2module($string) Converts a perl file name to a perl module name (Foo/Bar.pm -> Foo::Bar) module2file($string) Converts a perl module name to a perl file name ( Foo::Bar -> Foo/Bar.pm) runFunction(%params) Run a function whose name is computed at runtime and return its result. logger a logger object module the function namespace function the function name timeout timeout for function execution load enforce module loading first delay($second) Wait for $second. It uses sleep() or Win32::Sleep() depending on the Operating System. perl v5.14.2 2012-06-25 FusionInventory::Agent::Tools(3pm)
All times are GMT -4. The time now is 03:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy