LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-14-2005, 05:51 PM   #1
gfrair
LQ Newbie
 
Registered: Jan 2005
Posts: 20

Rep: Reputation: 0
File Searching


I am trying to write a script to find all files under a given file size.

I am using the following commands:

------------------------------------------------------------------------------------------
while [ $size -ge 0 ]
do
x=$(find /home -type f -printf %s'\t'%p'\n' | grep -b $size | wc -l)
let size=size-1
let n=n+x
done
------------------------------------------------------------------------------------------

therefore at the end, the variable 'n' is suppose to represent the number of files under the given file size. The only problem with this is that a file that has a size of 157, is counted for 157, 57, 15, 7, 5, & 1. So that single file is counted as 6 seperate files according to my stupid script.

If anyone has any suggestions on how to make a correct script or command to accomplish this task i would greatly appreciate it.

Thanks,
 
Old 03-14-2005, 06:24 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
find -size -1000 -type f -printf %s'\t'%p'\n' | awk '{allup+=$1}END{print allup, NR}'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[c] searching for a word in a file saiz66 Programming 1 10-04-2004 09:46 PM
Searching patterns from file MichaelVaughn Programming 1 04-06-2004 11:18 AM
File Searching JC404 Linux - Newbie 2 08-02-2003 08:45 PM
searching through a file albean Linux - Newbie 8 11-23-2002 08:16 PM
searching through a binary file mccareth Programming 3 04-08-2002 05:51 PM


All times are GMT -5. The time now is 04:52 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration