how can i write the modified dates of all of the files in my directory to a file. i dont want any of the other junk from ls in there. i cant use the cut command
Why can't you use cut? And do you want the filename with the date of last modification?
Hi Cypher,
You can use this:
ls -sl | awk '{print $9,$10} > file.out
to accomplish what you want. You may have to adjust $9 and $10 depending on your system output. I ran this on Solaris 8. IF you have never used awk, the above statment will essentially copy columns 9 and 10 of the ls -sl output info the log file and nothing else. In my case, column 9 is the time and 10 is the filename. If you don't want the filename, simply remove the ",$10" from above. Also, you could change the ls command from ls -sl to ls -c if you wanted to learn when the file permissions, ownership, etc were last changed. You may have to change 9 and 10 again to compensate for your system output.
hi,guey.
you could try like this:
touch <filename>:D
Heres another:
(ls -la|while read a b c d e f; do echo $e; done) > myfile
or another, if you want only files (not directories):
find . -type f -exec ls -l {} \; | awk '{print $5}' > myfile
(This is how I personally would do it...)