help required in program


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help required in program
# 1  
Old 11-06-2011
help required in program

I have below code, i need to modify it, to search for files (*.php,*.css,*.html) in those directores which have 777 permission, how to modify this code. Because it is moving all files.

Code:
while true
do
        sleep 60

        DATE=$(date +%Y-%m-%d)

        # Creates dir only if it doesn't already exist
        mkdir -p /garbage/${DATE}/

        find ./ '(' -name '*.php' -o -name '*.css' -o -name '*.html' ')' -exec mv '{}' /garbage/${DATE}/ ';' -print > /tmp/$$

        if [ -s /tmp/$$ ]
        then
                echo "Files moved on $(date)"
                cat /tmp/$$
        fi >> /path/to/logfile

        rm -f /tmp/$$
done

# 2  
Old 11-06-2011
Quote:
Originally Posted by learnbash
I have below code, i need to modify it, to search for files (*.php,*.css,*.html) in those directores which have 777 permission, how to modify this code. Because it is moving all files.

Code:
while true
do
        sleep 60

        DATE=$(date +%Y-%m-%d)

        # Creates dir only if it doesn't already exist
        mkdir -p /garbage/${DATE}/

        find ./ '(' -name '*.php' -o -name '*.css' -o -name '*.html' -perm 777 ')' -exec mv '{}' /garbage/${DATE}/ ';' -print > /tmp/$$

        if [ -s /tmp/$$ ]
        then
                echo "Files moved on $(date)"
                cat /tmp/$$
        fi >> /path/to/logfile

        rm -f /tmp/$$
done

# 3  
Old 11-06-2011
I am searching on directories base. search for those directories which have 777 permission then search is there any php, css, html script exist or not.

---------- Post updated at 10:00 AM ---------- Previous update was at 09:42 AM ----------

i have total 4 directories which are 777 permission, if i will use above code, so i will specifiy and run this code time, while i want to modify the script in such a way it will get first 777 directories first and search in that directory is there any php,html,css exist then move it. I am not understanding that part to add directory checking which have 777 permission.
# 4  
Old 11-06-2011
Try this...
Code:
find . -perm 777 -type d | find . -name "*.php" -exec ...

The first command will find you the directories with permission 777 and then you can search those directories for what you want and do whatever you want with them...

HTH
--ahamed
# 5  
Old 11-06-2011
Code:
 find ./ -type d -perm 0777

i want to add above code so it will search first 777 directories and then check php,css,html file respectively under 777 found directories. I hope everyone understand now.
# 6  
Old 11-06-2011
That is what I have given... Check my post... Pipe it to your command...

--ahamed
# 7  
Old 11-06-2011
ahmed bahi, i am using below code, but it is showing me all php,html. while it will show only two file.

Code:
find . -perm 777 -type d |  find ./ '(' -name '*.php' -o -name '*.css' -o -name '*.html' ')'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl program get a response before the program quits

I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade. I have: if ( $response =~ m/^/ ) { $user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies

2. Homework & Coursework Questions

Calling compiled C program with Perl program

Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies

3. Programming

Python program faster than C++ program.

I wrote a simple program that generates a random word 10,000,000 times. I wrote it in python, then in C++ and compared the two completion times. The python script was faster! Is that normal? Why would the python script be faster? I was under the impression that C++ was faster. What are some of... (2 Replies)
Discussion started by: cbreiny
2 Replies

4. Programming

Why is required to leave an empty line at the end of a C program?

I know it looks like a stupid question, but i really wanna know the reason. Actually, i think it's because the c compiler will detect it as the end of file "EOF" of the program, but, am i wrong? because it compiles it anyway, but keep showing warnings like "no new line at the end of file". I... (8 Replies)
Discussion started by: semash!
8 Replies

5. Shell Programming and Scripting

simple program help required

The circumfrence of a circle is #!/usr/bin/perl print 2 * 3.141592654 * 12.50 \n"; # pi= 3.141592654 # r= 12.50 I need a simple program showing me all the steps..to modify the above to prompt for and accept a radius from the person running the... (3 Replies)
Discussion started by: Q2wert
3 Replies

6. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

7. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

8. UNIX for Dummies Questions & Answers

Shell program:Help required on file formating

I have two files file1 and file2 as shown below: file1: name nameabc bcd nameabcdefg file2: age age1111 age2345 age6743 I have pasted one file on the other with the delimiter "|" and the resulttant file is: name|age nameabc|age1111 bcd|age2345 nameabcdefg|age6743 (6 Replies)
Discussion started by: udiptya
6 Replies

9. Shell Programming and Scripting

Very Urgent help required in Shell Program

How do I Ftp, and rename multiple files in one unix script. I have to send it with .tmp extension , then rename it to .txt after FTP is done . I need to do a Mass rename of more than 1 file in a shell script , Urgent help required. (1 Reply)
Discussion started by: Suppandi
1 Replies

10. Programming

A C program required for portability

I have to solve a problem for my wife who is engaged in Research in Breast Cancer. 1. She has frequently to search a long single line of alphabetic characters (lower case) for an exact match of a string. e.g.... (1 Reply)
Discussion started by: nmsinghe
1 Replies
Login or Register to Ask a Question