Find function script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find function script
# 1  
Old 02-13-2013
Find function script

Hi everybody,

I want your help on what, I suppose, might seem a simple task to many of you.

the deal is to write a script that will look in a specific folder to see if there is any file whose size is bigger than say 1M and if so to execute a command.

like

if [find . -type f -size +100000]
then
log_rotate
fi

the idea is to rotate a log file after it reaches a certain size.

I guess there are better ways to do this.

please advise

Lorenc
# 2  
Old 02-13-2013
Code

Please modify print$5 for correct column for size.

Code:
for $ln `ls -l dirpath`
do
 size=`echo $ln | awk '{print $5}
if [ $size -gt 1000000 ]
#### here goes your command
fi

done

# 3  
Old 02-13-2013
Have a look at the logrotate command: man logrotate
# 4  
Old 02-13-2013
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

find function

Hi, There is requirement where I need to search if a particular directory name is present or not and if its present I need to collate the paths of the directories in a file. I tried the below command echo $(find /home/mqm -name "check")>>config.txt Its saving the paths in one line(like... (7 Replies)
Discussion started by: jayii
7 Replies

3. Homework & Coursework Questions

Shell script calling Perl function, sort and find data, write to new files

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies

4. Shell Programming and Scripting

Find C function definition in from Shell script

Hi, I am having list of C function names say function1 function2 function3 and i am having many source files under my current directory. Now i would like to find the file names which contains the function definition from my list. It would be appreciable if... (1 Reply)
Discussion started by: tsaravanan
1 Replies

5. Shell Programming and Scripting

use File::Find function

Hello, I'm learning the perl's Find function using unix but I keep getting this error when running the script: "Not a CODE reference at /usr/lib.perl5/5.8.8/File/Find.pm line 822" - what does this mean? Does anyone know??? Here's my script: use File::Find; find (\$dir,$ENV{HOME}); ... (4 Replies)
Discussion started by: new bie
4 Replies

6. Shell Programming and Scripting

find function name in a program file

Hello All, Is there any way to find a function name in a program file using perl. for example, there is a file called Test.C in that . . void function1(..) { <some code> } int function2(..) { . . sam() /*RA abc100*/ ... .. .. xyz()/*RA abc201*/ .. (8 Replies)
Discussion started by: Parthiban
8 Replies

7. Shell Programming and Scripting

SHELL SCRIPT Function Calling Another Function Please Help...

This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord but only one record is getting wrote in DB.... Please advise ASAP...:confused: function InsertFtg { FTGSTR="" echo "Saurabh is GREAT $#" let... (2 Replies)
Discussion started by: omkar.sonawane
2 Replies

8. Shell Programming and Scripting

help with find function

Hi, Im using a find function to find a specific file and print it. eg. find /path -name filename -type f -print -exec more '{}' \; The problem I have is that I need to know if the file has not been fount (ie it does not exist). I had a look at the find function and could not find anything... (4 Replies)
Discussion started by: strobo
4 Replies

9. Shell Programming and Scripting

script to find function names

hi, i am a newbie and have to write a rather complicated script. Assume that i have a variable called x and a C source code file say file1.c (these are the inputs of the script) and i need to find the names of all the functions in the C file containing x.Take the following code as an example: ... (2 Replies)
Discussion started by: samantha grace
2 Replies

10. UNIX for Dummies Questions & Answers

find function

I was trying the following "find" command to search for a particular file in UNIX directories: find / -name <filename> -print Result on the screen appears like: find: cannot open <..> ..permission denied Is there any way, I could avoid these type of search results and only see the... (2 Replies)
Discussion started by: pkumar_syd
2 Replies
Login or Register to Ask a Question