LinuxQuestions.org
Visit Jeremy's Blog.
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 06-01-2003, 08:37 AM   #1
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Rep: Reputation: 15
need help with shell script


Hi!

I need a shell script which looks for files in a directory >700MB
and if it finds one do a job like mencoder file ... rm file ...

THX SchwipSchwap
 
Old 06-01-2003, 09:59 AM   #2
markus1982
Senior Member
 
Registered: Aug 2002
Location: Stuttgart (Germany)
Distribution: Debian/GNU Linux
Posts: 1,467

Rep: Reputation: 46
Take a look at find: man find
 
Old 06-01-2003, 10:59 AM   #3
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
find -size +1600000 will find files about 795mb right ?!
how can i -exec commands at the found files ?

THX SchwipSchwap
 
Old 06-01-2003, 11:32 AM   #4
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
example
-exec rm {} \;
the results of the find command are put where the
brackets are.

find . -name file -exec rm {} \;
 
Old 06-01-2003, 03:29 PM   #5
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
k if i start:
find -size +1600000 -exec myscript {} \;

//myscript

if [ "$1" != "" ]; then
mencoder $1 -vop scale -xy 640 -ovc lavc -lavcopts vcodec=mpeg4:vratetol=5830082 -oac copy -o $1\ resize695mb.AVI
fi

if ["$2" != ""]; then

...

//endmyscript

all files >795MB will be encoded

but theres something wrong with the $1 $2 ...

THX for any help
SchwipSchwap
 
Old 06-01-2003, 03:32 PM   #6
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
i also need a script which moves all files ending with .avi in a directory to an other directory
 
Old 06-01-2003, 03:49 PM   #7
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
i think you need to put it all in a row like

find -size +1600000 -exec mencoder {} -vop scale -xy 640 -ovc lavc -lavcopts vcodec=mpeg4:vratetol=5830082 -oac copy -o {} resize695mb.AVI \;

i haven't experimented with that type of thing yet though.
you might also look at xargs. ( man xargs )
 
Old 06-01-2003, 03:58 PM   #8
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
didnt work but problem is solved now
files are deleted

SchwipSchwap
 
Old 06-01-2003, 04:08 PM   #9
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
if you call deleting files "solving problems",
then you ought to get a job as a sysadmin.

maybe you should download the fileutils source, and
edit rm where it says "files deleted", change that
to "problems solved".

Last edited by whansard; 06-01-2003 at 04:09 PM.
 
Old 06-01-2003, 04:14 PM   #10
SchwipSchwap
Member
 
Registered: Aug 2002
Distribution: Suse8.0, Mandrake, Knoppix
Posts: 92

Original Poster
Rep: Reputation: 15
the line with copy -o {} resize 695mb.AVI was wrong
mencoder only took -o {}

so all files where deleted

SchwipSchwap

PS: $L is for all parameters parsed or?

Last edited by SchwipSchwap; 06-01-2003 at 04:16 PM.
 
Old 06-01-2003, 04:41 PM   #11
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
this is all i know


-exec command ;
Execute command; true if 0 status is returned. All
following arguments to find are taken to be argu_
ments to the command until an argument consisting
of `;' is encountered. The string `{}' is replaced
by the current file name being processed everywhere
it occurs in the arguments to the command, not just
in arguments where it is alone, as in some versions
of find. Both of these constructions might need to
be escaped (with a `\') or quoted to protect them
from expansion by the shell. The command is exe_
cuted in the starting directory.
 
Old 10-22-2003, 06:10 PM   #12
SpecialOps
LQ Newbie
 
Registered: Oct 2003
Location: Bilzen
Distribution: Debian, Mandrake, Slackware
Posts: 11

Rep: Reputation: 0
Hi

I need a script that executes an other script at a certain time of the day

at 9 o clock in the morning i want this script to run e.g. script1
(./script1)
and i want it to stop the script at an other time of the day

in other words, i need a script that can start and stop programs at a specified time interval.

How do i do this? I already have this code:

#!/usr/local/bin/bash

What do i do next? Sorry but i'm an absolutely newbie at linux and i want to learn it.

Thanks in advantage
Greetz Fabio Tielen
 
Old 10-22-2003, 06:23 PM   #13
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
thats what cron is for.
look at /etc/crontab
 
Old 10-22-2003, 06:34 PM   #14
SpecialOps
LQ Newbie
 
Registered: Oct 2003
Location: Bilzen
Distribution: Debian, Mandrake, Slackware
Posts: 11

Rep: Reputation: 0
I have found the directory cron.hourly

But what do i with this?

Greetz Fabio
 
Old 10-22-2003, 07:12 PM   #15
SpecialOps
LQ Newbie
 
Registered: Oct 2003
Location: Bilzen
Distribution: Debian, Mandrake, Slackware
Posts: 11

Rep: Reputation: 0
I have found a little bit more code. Now I have this:

#!/usr/local/bin/bash
hour='date | cut -c12-13'
if [ $hour -lt 12 ]
then
command
fi


But it doesn't work can someone help me figure this out?

Thanks

Greetz Fabio
 
  


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
Shell script inside shell script treotan Linux - General 4 02-19-2009 07:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 06:32 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-12-2005 12:08 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM


All times are GMT -5. The time now is 06:42 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration