Skip to main content
deleted 70 characters in body; edited tags
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

In the following command, how can I get the file names based on its timestamp

 $ grep "exit 0" a*  a1.txt:+ exit 0  a2.txt:+ exit 0  a3.txt:+ exit 0  a4.txt:+ exit 0  a5.txt:+ exit 0  $ ls -latr  -rw-r--r-- 1 user grp 83046 Oct 27 06:46 a5.txt  -rw-r--r-- 1 user grp 68108 Oct 27 07:59 a1.txt  -rw-r--r-- 1 user grp 159792 Oct 27 12:35 a2.txt  -rw-r--r-- 1 user grp 225703 Oct 27 16:41 a3.txt  -rw-r--r-- 1 user grp 246782 Oct 27 20:17 a4.txt 

IfAs you see tehthe above output, I am not getting the output based on the timestamp the file was created. IsIs there any way to achiveachieve it?

In the following command, how can I get the file names based on its timestamp

  grep "exit 0" a*  a1.txt:+ exit 0  a2.txt:+ exit 0  a3.txt:+ exit 0  a4.txt:+ exit 0  a5.txt:+ exit 0   ls -latr  -rw-r--r-- 1 user grp 83046 Oct 27 06:46 a5.txt  -rw-r--r-- 1 user grp 68108 Oct 27 07:59 a1.txt  -rw-r--r-- 1 user grp 159792 Oct 27 12:35 a2.txt  -rw-r--r-- 1 user grp 225703 Oct 27 16:41 a3.txt  -rw-r--r-- 1 user grp 246782 Oct 27 20:17 a4.txt 

If you see teh above output, I am not getting the output based on the timestamp the file was created. Is there any way to achive it?

In the following command, how can I get the file names based on its timestamp

$ grep "exit 0" a* a1.txt:+ exit 0 a2.txt:+ exit 0 a3.txt:+ exit 0 a4.txt:+ exit 0 a5.txt:+ exit 0 $ ls -latr -rw-r--r-- 1 user grp 83046 Oct 27 06:46 a5.txt -rw-r--r-- 1 user grp 68108 Oct 27 07:59 a1.txt -rw-r--r-- 1 user grp 159792 Oct 27 12:35 a2.txt -rw-r--r-- 1 user grp 225703 Oct 27 16:41 a3.txt -rw-r--r-- 1 user grp 246782 Oct 27 20:17 a4.txt 

As you see the above output, I am not getting the output based on the timestamp the file was created. Is there any way to achieve it?

Source Link
janani
  • 137
  • 2
  • 7

How to sort the filenames shown in grep command based on timestamp?

In the following command, how can I get the file names based on its timestamp

 grep "exit 0" a* a1.txt:+ exit 0 a2.txt:+ exit 0 a3.txt:+ exit 0 a4.txt:+ exit 0 a5.txt:+ exit 0 ls -latr -rw-r--r-- 1 user grp 83046 Oct 27 06:46 a5.txt -rw-r--r-- 1 user grp 68108 Oct 27 07:59 a1.txt -rw-r--r-- 1 user grp 159792 Oct 27 12:35 a2.txt -rw-r--r-- 1 user grp 225703 Oct 27 16:41 a3.txt -rw-r--r-- 1 user grp 246782 Oct 27 20:17 a4.txt 

If you see teh above output, I am not getting the output based on the timestamp the file was created. Is there any way to achive it?