Reputation: 110163
To get the full timestamp of a file, I can do:
$ ls -lT
However, when I try the following:
find . -ls -lT
I get an find: -lt: unknown primary or operator
(using find . -ls
works).
What would be the correct way to use the find
+ ls -lT
command?
Upvotes: 0
Views: 10125
Reputation: 93636
If you're parsing the output of ls
, you're doing it wrong. There's always a better way to interface with the filesystem than parsing human-readable output.
I'm not sure what you mean by the "full timestamp of the file", but if you want, say, the last modification time, use stat
.
stat --printf='%x' foo
2013-01-29 13:33:32.000000000 -0600
Run man stat
to see all the other formatting options in the --printf
argument.
Upvotes: 3
Reputation: 12043
The find "-ls" option isn't running ls and doesn't accept all its arguments. That said, I don't know why you want the -T argument, which is an obscure thing involving tab stops that I had to look up. But broadly, you just want to run a command ("ls -lT" in this case) on a bunch of files found by find. So any of the following should work: find . -type f | xargs -n1 ls -lT
or find . -type f -exec ls -lT {} ';'
or for i in $(find . -type f); do ls -lT $i; done
.
Or, for the special case of ls that takes more than one command line argument, just find . -type f | xargs ls -lT
Upvotes: 4