User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 427,430 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,632 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1479 | Replies: 2
Reply
Join Date: Apr 2006
Posts: 2
Reputation: problems is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
problems problems is offline Offline
Newbie Poster

searching for files

  #1  
Apr 28th, 2006
i would like to find files that have been modified during a month. lets say i am type in 2004 06
it will find files in the month of june.
i know using l -la lista all the files and thier attrbutes. and one of thier attributtes is last modified time. can i somehow search for files using the modified time attrbute of the file

is there also a way to convert a numberic date to a textual date e.g. like
06 2006 to jun 2006

need help urgently

thanks

AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2006
Location: India
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: searching for files

  #2  
Apr 28th, 2006
make a file with name of the month and the month in numeral format.

Say,

Jan 01
Feb 02
March 03

store the year and month in two different variable.

grep the month from the file containing the month and the corresponding number.

use awk to print the month name and year.

Do a ls -Ral and grep the month and year.

Try this out. It works.

Amit
Reply With Quote  
Join Date: Apr 2006
Posts: 4
Reputation: ranj@chn is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ranj@chn ranj@chn is offline Offline
Newbie Poster

Re: searching for files

  #3  
Apr 28th, 2006
Originally Posted by problems
i would like to find files that have been modified during a month. lets say i am type in 2004 06
it will find files in the month of june.
i know using l -la lista all the files and thier attrbutes. and one of thier attributtes is last modified time. can i somehow search for files using the modified time attrbute of the file

is there also a way to convert a numberic date to a textual date e.g. like
06 2006 to jun 2006

need help urgently

thanks



You can use 'case' function to name the month parameter like
LEts suppose inside the script
$1-06
$2 - 2006
case $1 in
01)) month="Jan" ; break;;
02)) month="Feb" ; break;;
.
.
.
.
.
and then grep for the 'month' and year variable from the ls output.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 5:27 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC