Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show time stamp

Status
Not open for further replies.
Apr 30, 2003
56
US
The find command:
system ("find /directory -name filename");
only return the full directory path where the file is belong to. How to make it show the time stamp too? Please help. Thanks.
 
Well this depends on the platform. HP does not have a built in -ls function in find from what I can see. You will have to use the -exec command with find.

AIX - find /tmp/junk -name test.txt -ls
196 28 -rwxr-xr-x 1 user users 25241 Mar 12 2001 /tmp/junk/test.txt

This should work with MOST versions of UNIX.

 
I have the info on HP as well....

HP => find /tmp/junk/ -name test.txt -exec ls -l {} \;

Hope this helps....
 
Thank you very much. This really helps. However, I run into another problem. The results returned from find command only display on the screen or stdout. How can I make it write to a file?
 
eileen,

You can use the standard redirection facilities, you can push the output of most commands into a file, like this:

ls -l > /tmp/a.file

The portion in red, above, is the part that puts the output of the ls command into the file.



Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Mike,

I've tried your command. It doesn't seem to work in my case.
Is ls -l > /tmp/a.file a perl script command, or do I have to include it in system () function?

Here is what I am trying to do. I issued command:
system ("find $dir1 -name **$a5** -ls");
I try to write this result to a file, not on the screen. What should I do? Please help. Thanks.
 
Yes, you have to include it in a call to the system() function;

like this Eileen,

system ("find $dir1 -name **$a5** -ls > /tmp/a.file");


Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top