help with finding specific files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help with finding specific files
# 1  
Old 10-20-2008
help with finding specific files

before i get to it, i would like to say this is the greatest unix site ive ever seen, and im glad to see so many people are out there to help. thanks

well, im trying to make myself a script where i can specify a directory and a file size so that my script will show me any files larger than the size i specify.

im using the find command, like so:

find $1 -type f -size +$2k -print

i know its not right because ive already run it and recieved errors and i pretty much modified that line from the find man page. any help or pointers would be appreciated

thanks
# 2  
Old 10-20-2008
Assuming GNU find (given your nick):

Code:
show_bigger(){ find -type f -size +"$1" -ls 2>/dev/null;}

For example:

Code:
% show_bigger 10M
1550976 66296 -rw-r--r--   1 root     root     67810654 Sep  9 20:25 ./sqldeveloper_1.5.54.40-2_all.deb
1550982 66308 -rw-r--r--   1 radoulov radoulov 67825452 Sep  9 20:24 ./sqldeveloper-1.5.54.40-1.noarch.rpm
819309 27012 -rw-r--r--   1 radoulov radoulov 27624080 Oct 16 11:58 ./fuz2y_desktop_theme_v1.2.tar.gz

Just saw you want to pass the path too, so:

Code:
show_bigger(){ find "$1" -type f -size +"$2" -ls 2>/dev/null;}

In zsh you could use (size is in bytes):

Code:
print -rl -- **/*(.DL+10000000)


Last edited by radoulov; 10-20-2008 at 04:51 PM..
# 3  
Old 10-21-2008
Let me try to separate each command for you

find $1 -type f -size +$2k -print

at this line $1 and $2 work as a parsing variable that usually work when you make application and run it from unix using ./(app_name) (parameter).

find $1 : you must fill $1 with path, exp: /user or . (for current dir) or /home
-type f : means the type that your looking was a file
-size +$2k :fill $2 with number exp: 1,2,3 that remark size of file your looking for +2K means search for file bigger than 2 KB
-print : show the result on the screen

good luck, keep on UNIX Smilie
# 4  
Old 10-21-2008
thanks guys, im gunna give it a shot n see how it goes
# 5  
Old 10-21-2008
actually i have a question, the 2>/dev/null; is that for error redirection?
# 6  
Old 10-21-2008
Quote:
Originally Posted by linuxlaptop
actually i have a question, the 2>/dev/null; is that for error redirection?
Yes.
(message too short)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding lines of specific size in files using sed

i am using sed to detect any lines that are not exactly 21. the following gives me the lines that ARE exactly 21. i want the opposite , i want the two lines that are not size 21 (shown in bold) type a.a 000008050110010201NNN 000008060810010201NNN 21212000008070110010201NNN... (5 Replies)
Discussion started by: boncuk
5 Replies

2. UNIX for Dummies Questions & Answers

Finding Files only under a specific FileSystem

Hi, I am using AIX and one of my file systems is getting filled up and I need to track with files are occupying more volume. Filesystem GB blocks Free %Used Iused %Iused Mounted on /dev/nhdb_lv 2110.00 63.80 97% 76525 1% /nhdb under the Mount Point /nhdb... (1 Reply)
Discussion started by: zulfi123786
1 Replies

3. Shell Programming and Scripting

Finding 4 current files having specific File Name pattern

Hi All, I am trying to find 4 latest files inside one folder having following File Name pattern and store them into 4 different variables and then use for processing in my shell script. File name is fixed length. 1) Each file starts with = ABCJmdmfbsjop letters + 7 Digit Number... (6 Replies)
Discussion started by: lancesunny
6 Replies

4. Shell Programming and Scripting

finding file with a specific range

Hi All, Thanks in advance File is generated with following format 31000000.xml to 48999999.xml 74000000.xml to 88999999.xml Above range should be find and moved into the folder named abc and below is another range should should be find and moved into folder named xyz ... (1 Reply)
Discussion started by: sujit_kashyap
1 Replies

5. Shell Programming and Scripting

Finding minimum value out of specific rows

Hi all, I am having multiple files with the pattern given below: I need to find the minimum value of 5th column if column 1 is x and 2nd column is awh or vbn or ... (20 different strings). the output must be like: Kindly help me to figure out this prob.... Thanks in... (4 Replies)
Discussion started by: CAch
4 Replies

6. Shell Programming and Scripting

Finding a specific word

Hi, I am trying to develop a script which should find a word if a particular word exists. Below is the content of the file. insert_job: test_job ----> job name days_of_week: all start_times: "16:00" date_conditions: 1 insert_job: test_job2 ----> job name days_of_week: all... (16 Replies)
Discussion started by: rpatty
16 Replies

7. Shell Programming and Scripting

Finding file in specific subdirectories

Hi experts problem: i have a directory "DATA" with lots of subdirectories named as date with hudge data containning files. Directory = "DATA" subdirectory = "20090611" & "20090612" ...... 20090611 = thousands of files i wanna apply find command to find all files in... (3 Replies)
Discussion started by: The_Archer
3 Replies

8. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

9. Shell Programming and Scripting

Finding a specific pattern from thousands of files ????

Hi All, I want to find a specific pattern from approximately 400000 files on solaris platform. Its very heavy for me to grep that pattern to each file individually. Can anybody suggest me some way to search for specific pattern (alpha numeric) from these forty thousand files. Please note that... (6 Replies)
Discussion started by: aarora_98
6 Replies

10. UNIX for Dummies Questions & Answers

finding specific values in a within a file

Hi everyone, Can anyone guide me on how to search through a huge file and look on specific column and if it finds a discrepancy on that column that does not conform to the specified criteria, ie (1) Numeric and (3) alpha chars F123 or G333..etc, etc! then idientify it and redirect... (3 Replies)
Discussion started by: Gerry405
3 Replies
Login or Register to Ask a Question