Find age of files...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find age of files...
# 8  
Old 10-05-2009
omnibus_procedure_scripts is a directory.

---------- Post updated at 03:54 AM ---------- Previous update was at 03:53 AM ----------

Still not sure I am getting what I am after....

I need to search only the directory I am in for any .arc files (no sub directories) and I need to turn the results into a count.
It seems like the find command works in the current directory but also drills into all sub directories.

So for example if there was 3 files with the ext .arc then the results returned would be 3.
That way I can look at the result number to see if any were found.

Also I am using this on Solaris and Linux so I am not sure if the commands would be the same.

Thank you for the help.
# 9  
Old 10-05-2009
Quote:
Originally Posted by LRoberts
omnibus_procedure_scripts is a directory.

---------- Post updated at 03:54 AM ---------- Previous update was at 03:53 AM ----------

Still not sure I am getting what I am after....

I need to search only the directory I am in for any .arc files (no sub directories) and I need to turn the results into a count.
It seems like the find command works in the current directory but also drills into all sub directories.

So for example if there was 3 files with the ext .arc then the results returned would be 3.
That way I can look at the result number to see if any were found.

Also I am using this on Solaris and Linux so I am not sure if the commands would be the same.

Thank you for the help.
Code:
if you put the syntax like below you will search the current directory only.

find /path/of/the/directory/*.arc  -mtime +1  2>/dev/null
                            ^^^^ #file name
if you write the syntax like below you will search the directory and its sub-directory

find /path/of/the/directory  -name "*.arc"  -mtime +1  2>/dev/null
                                     ^^^^ #file name

BR
# 10  
Old 10-05-2009
Ok I see what you mean now :-)
Yes that does seem to work. Now how would I turn that into a count though for the output? For example if it does find a .sh file.

For example if there are 3 files in that directory...

file1.pl
file2.sh
file3.pl

And I do the command it should come back with a result of
1

Because there was only 1 file with a .sh ext. If there are none then it should result in a 0 for the output.

Thanks again for the help.

---------- Post updated at 04:28 AM ---------- Previous update was at 04:24 AM ----------

Ok I think its close....
kraken:/lcl/prd/data/entp/archives>find /lcl/prd/data/entp/archives/*.arc -mtime +1 2>/dev/null | wc -l
0

Only thing is why does the 0 show up so much to the right on Solaris?
# 11  
Old 10-05-2009
Quote:
Originally Posted by LRoberts
Ok I see what you mean now :-)
Yes that does seem to work. Now how would I turn that into a count though for the output? For example if it does find a .sh file.

For example if there are 3 files in that directory...

file1.pl
file2.sh
file3.pl

And I do the command it should come back with a result of
1

Because there was only 1 file with a .sh ext. If there are none then it should result in a 0 for the output.

Thanks again for the help.

---------- Post updated at 04:28 AM ---------- Previous update was at 04:24 AM ----------

Ok I think its close....
kraken:/lcl/prd/data/entp/archives>find /lcl/prd/data/entp/archives/*.arc -mtime +1 2>/dev/null | wc -l
0

Only thing is why does the 0 show up so much to the right on Solaris?
Code:
Just pipe the output to wc -l command

find /path/of/the/directory/*.arc  -mtime +1  2>/dev/null | wc -l

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Age of file

Hi All.. Is there any easy way to find out how many days older is file? for ex. fileA 20 days fileB 10 days I am currently on AIX, and there is no STAT command available in this environment. What are my options? Thanks Abhijeet R (1 Reply)
Discussion started by: freakabhi
1 Replies

2. AIX

Visual Age C++

hi , After i installed the visual age c++ its got installed but am not able to find the bin directory in the /usr/vacpp.am i need to install the some fileset ???? please help me.version is 7 mak (1 Reply)
Discussion started by: senmak
1 Replies

3. Shell Programming and Scripting

Perl Find file age

Hi I can not say that i am new to perl but today i learned something new, i wanted to know age (last time file got modified) of file so i initially thought of using find -mtime command but when i googled it, i found perl solution for the same my $age = -M $ARGV ; print "$ARGV age is... (1 Reply)
Discussion started by: zedex
1 Replies

4. Shell Programming and Scripting

file age

How can I count the age of the file (e.g. in minutes)? (4 Replies)
Discussion started by: jarmo.leppanen
4 Replies

5. Shell Programming and Scripting

Find the age of a file in Minutes

KSH: Please lt me know how to find the age of a file in minutes(Based on last modified time). ie, if the file was modified 15 Minutes ago, the output should be 15 (1 Reply)
Discussion started by: hari_anj
1 Replies

6. What is on Your Mind?

What is your age? (Part 2)

What is your age? poses an interesting question, but the age categories had some room for improvement. So I thought that I would start a new poll with with a better distribution of age groups. As with the other poll, this is a public poll. People can click on the numbers to see who voted and... (37 Replies)
Discussion started by: Perderabo
37 Replies

7. What is on Your Mind?

What is your age?

What is your age? (15 Replies)
Discussion started by: royal
15 Replies

8. UNIX for Dummies Questions & Answers

find a process age

I can write a script to use ps and interigate the output, but is there a command that works similar to the find command for files where I can request a list of all the running processes over 1 day old ? thanks! (8 Replies)
Discussion started by: MizzGail
8 Replies

9. UNIX for Dummies Questions & Answers

How to find the File Age and wait for that...

Hi, I want to know my file is 1 hr 30 min old or not, If 1 hr 30 min old I will do some tasks in that file.. other wise I will wait to 1 hr 30 min and then do the tasks.. how to do it in Unix script? any idea? (3 Replies)
Discussion started by: redlotus72
3 Replies
Login or Register to Ask a Question