Sponsored Content
Top Forums Shell Programming and Scripting Script to determine Date,TotalFile,total size of file based on date Post 302927301 by Don Cragun on Tuesday 2nd of December 2014 02:55:00 AM
Old 12-02-2014
This is similar to your script adding the size (as long as you don't mind actual byte counts instead of sums of "human readable" approximations):
Code:
printf '\nDATE\tFILES\tSIZE\n'
cd /Mydir
ls -lrt | grep "^-" | awk '
{	key=$6$7
	freq[key]++
	size[key] += $5
}
END {	for (date in freq)
		printf("%s\t%d\t%d\n", date, freq[date], size[date])
}'

Like your script, the output is not necessarily in date order. If you'd like the output in date order, you could try something more like:
Code:
printf '\nDATE\tFILES\tSIZE\n'
cd /Mydir
ls -lrt | grep "^-" | awk '
{	nkey = $6$7
	if(key != nkey && key != "") {
		printf("%s\t%d\t%d\n", key, freq, size)
		freq = 1;
		size = $5
	} else {freq++
		size += $5
	}
	key = nkey
}
END {	printf("%s\t%d\t%d\n", key, freq, size)
}'

Neither of these have been tested, but they should come close to what you need. I will leave the conversion of actual bytes to human readable form as an exercise for the reader. (I prefer the actual byte counts.)

If you want to use panyam's code I think you would need to change all occurrences of a[freq[key]] to a[key] and change a[freq[date]] to a[date].
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Determine date and time the file was created through shell scripts

Can I determine when the particular file was created, in korn-shell. Can please someone help me. If possible please mail the solution to me. my mail id: bharat.surana@gmail.com (1 Reply)
Discussion started by: BharatSurana
1 Replies

2. Shell Programming and Scripting

sort files by date, delete oldest, if total size bigger than

hello people i need your help please i want to achieve the following with the simplest, most efficient shell-tools: i have a directory with a lot of files from users. the script should check which partition the dir is on if the partition with the directory is more than 90% full ... (2 Replies)
Discussion started by: scarfake
2 Replies

3. Shell Programming and Scripting

Perl Script to check file date and size

Hi guys, i am new to perl. I started reading the perl documents and try to come up with some logic. I am trying to create a script that would go into a location, search for todays files, then searches for all .txt files from today. If todays not found, its an error If file size is less... (26 Replies)
Discussion started by: DallasT
26 Replies

4. Shell Programming and Scripting

How to FTP the latest file, based on date, from a remote server through a shell script?

How to FTP the latest file, based on date, from a remote server through a shell script? I have four files to be FTP'ed from remote server. They are of the following format. build1_runtime_mmddyyyy.txt build2_runtime_mmddyyyy.txt build3_runtime_mmddyyyy.txt buifile_count_mmddyyyy.txt ... (9 Replies)
Discussion started by: imran_affu
9 Replies

5. Shell Programming and Scripting

Checking the total size of all files from a particular date

Hi I have some set of files for a particular date. What is the command that I need to put in for finding the total size of all the files for that particular date. The following command is fetching me the size of all individual files seperately du -h *20101010* 16M file1.20101010 120K... (10 Replies)
Discussion started by: bobby1015
10 Replies

6. Shell Programming and Scripting

Needed shell script to get the latest file based on date

hi i need the shell script to get the file with latest date. for example in my input folder i have files like file_20130212.txt file_20130211.txt now my output folder should have the file with latest date i.e..file_20120212.txt i want to get the latest file .. i.e is should take... (6 Replies)
Discussion started by: hemanthsaikumar
6 Replies

7. UNIX for Dummies Questions & Answers

Looking for command line to find dirs based on size and date

Hi, My first time on this site, please excuse me if I've come to the wrong forum. I'm fairly new to Unix/Linux and hoping you can help me out. I'm looking for a command line that will return a list of directories that are larger than 50M and older than 2 days. I thought it may be... (6 Replies)
Discussion started by: Wisconsingal
6 Replies

8. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies

9. HP-UX

HP/UX command to pull file name/date based on date

HI, Can anyone tell me how to pull the date and file name separated by a space using the find command or any other command. I want to look through several directories and based on a date timeframe (find -mtime -7), output the file name (without the path) and the date(in format mmddyyyy) to a... (2 Replies)
Discussion started by: lnemitz
2 Replies

10. UNIX for Beginners Questions & Answers

Run shell script based on date file

Hi Team, I have a to run a script based on a date present in a different file which updates everyday. Kindly help with the solution. My current execution : ksh scriptname.sh 10152019. But here i want to enter this date from a file which gets updated daily. My appraoch : date file location:... (3 Replies)
Discussion started by: midhun3108
3 Replies
FM(1)							      General Commands Manual							     FM(1)

NAME
fmscan - scan FM band for radio stations SYNOPSIS
fm [ -h ] [ -d device ] [ -t tuner ] [ -s freq ] [ -e freq ] [ -i freq ] [ -q ] DESCRIPTION
fmscan is a program to scan a frequency band for radio stations, using the video4linux interface introduced in 2.1.x series Linux kernels. It shows which ones have a accumulated signal strength of 50% or higher. OPTIONS -h Print a usage message to standard output, and exit. -d device Sets device as the device to tune. The default is /dev/radio0. -t tuner Sets tuner as the tuner on the selected device to adjust. The default is tuner 0. Most radio devices have only a single tuner. -s freq Starting frequency for scan, in MHz. Default: 87.9. -e freq Ending frequency for scan, in MHz. Default: 107.9. -i freq Increment between scanned channels, in MHz. Default: 0.2. -t percent Signal strength threshold to consider a channel. Default: 50%. -q Quiet mode. Suppresses progress output. BUGS
This process can take a while, and results vary greatly depending on the radio card in use. If your card's hardware cannot report signal strength, it will not produce useful results. This program may not do much if your radio card's driver doesn't support fine tuning in 1/16000 MHz offsets. By default, V4L2 assumes 1/16 MHz tuning units, which introduces evil rounding errors on many frequencies. Supports only tuner 0 on any given device. SEE ALSO
Additional documentation: /usr/doc/fmtools/README The fmtools homepage: http://benpfaff.org/fmtools AUTHORS
Russell Kroll <rkroll@exploits.org>, now maintained by Ben Pfaff <blp@cs.stanford.edu.>. This manpage written by Ben Pfaff. fmscan 1.0.2 FM(1)
All times are GMT -4. The time now is 04:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy