Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-06-2007
Registered User
 

Join Date: Dec 2007
Posts: 41
Korne Shell Script...

I am trying to write a Korne Shell Script, wherein the user is prompted for a date and a directory and then it starts searching recursively in this directory the list of all the files modified after the date chosen.

I wrote the following Script but it seems to be not working :-

#!/usr/bin/ksh
typeset DATE=`date +%d%m%y`
echo "Enter a date (DDMMYY) and a directory.."
read files
Find "$dir’ -type f -name -mtime "$files"

Anyone, please let me know the correct way.

Thanks in advance.
Sponsored Links
  #2 (permalink)  
Old 12-06-2007
porter porter is offline Forum Advisor  
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by marconi View Post
Find "$dir’ -type f -name -mtime "$files"
it should be


Code:
find "$dir" -type f -name "$files" -mtime $N

where N is number of days old.
  #3 (permalink)  
Old 12-06-2007
Read Only
 

Join Date: Nov 2007
Posts: 165
There is no e in Korn.
  #4 (permalink)  
Old 12-06-2007
Registered User
 

Join Date: Dec 2007
Posts: 2
ummmm...to fix the code

#!/usr/bin/ksh
echo "Enter a date (YYMMDD) "
read dte
touch -t "$dte"0000 /tmp/$USER.ksh-search
echo "Enter a directory.."
read dir
find $dir -type f -newer /tmp/$USER.ksh-search
rm /tmp/$USER.ksh-search

but really, i like porters suggestion better :-)
  #5 (permalink)  
Old 12-06-2007
Registered User
 

Join Date: Oct 2007
Location: Wellington, New Zealand
Posts: 30
Quote:
Originally Posted by prowla View Post
There is no e in Korn.
Maybe he was confusing it with some other daemons:

Khorne - Wikipedia, the free encyclopedia

  #6 (permalink)  
Old 12-06-2007
Registered User
 

Join Date: Oct 2007
Location: Wellington, New Zealand
Posts: 30
Quote:
Originally Posted by porter View Post
it should be


Code:
find "$dir" -type f -name "$files" -mtime $N

where N is number of days old.
I'd make that:


Code:
find "$dir" -type f -name "$files" -mtime +$N

or you'll only find files exactly $N days old. He wants files that age or older if I read it correctly.
Sponsored Links
Closed Thread

Bookmarks

Tags
mtime

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Korne Shell... marconi Shell Programming and Scripting 1 12-06-2007 02:01 PM
Some Problem with Korne Shell// marconi Shell Programming and Scripting 4 12-06-2007 10:57 AM
Korne Shell Problem. marconi Shell Programming and Scripting 3 12-05-2007 04:30 PM
GOTO LOOP in KORNE SHELL DeepakXavier Shell Programming and Scripting 1 11-10-2005 12:47 PM
Mailing in Korne shell DeepakXavier Shell Programming and Scripting 5 10-09-2005 05:27 PM



All times are GMT -4. The time now is 01:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0