![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to compare size of two file which is in one directory | Aditya.Gurgaon | Shell Programming and Scripting | 1 | 01-08-2009 06:28 AM |
| write the script to get the file size and sends an email | s_linux | Shell Programming and Scripting | 10 | 08-13-2008 11:54 PM |
| Check File Exists and compare to previous day file script | rbknisely | Shell Programming and Scripting | 3 | 02-07-2008 11:53 AM |
| compare file size from a output file from a script | moustik | Shell Programming and Scripting | 7 | 11-07-2007 10:17 AM |
| How to write current Date dynamically in a file | Sree_2503 | Shell Programming and Scripting | 5 | 10-17-2006 05:19 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 compare the monthly files). so can anybody help me to find a solution for this. Any help would be greatly appreciated! |
|
||||
|
Code:
#!/bin/sh
FILE="xyzddddyymm.txt"
SIZES=( $(stat "--printf=\t%s" "${FILE}" "../${FILE}") )
if [[ "${SIZES[0]}" -gt "${SIZES[1]}" ]]
then
echo "${FILE} > ../${FILE} by $((SIZES[0]-SIZES[1])) bytes"
elif [[ "${SIZES[1]}" -gt "${SIZES[0]}" ]]
then
echo "../${FILE} > ${FILE} by $((SIZES[1]-SIZES[0])) bytes"
else
echo "${FILE} and ../${FILE} are the same size"
fi
|
|
||||
|
Quote:
i need one more help. But i am having 4 files in the current directory and 4 files in the previous dir. the file names will be same in both the dir, but with different dates. How can i compare all the files in this situation. can you please help me in this? |
|
||||
|
Repeat the above examples four times, with different dates? If that's not it, then a clearer explanation may be needed.
|
| Sponsored Links | ||
|
|