Hi,
On AIX , when I run: grep myexpression * -exec ls -lrt {} \;
I recive:
grep: 0652-033 Cannot open -exec.
grep: 0652-033 Cannot open ls.
grep: 0652-033 Cannot open -lrt.
grep: 0652-033 Cannot open {}.
grep: 0652-033 Cannot open ;.
Hi, grep doesn't have an -exec. option.
A 5 minute read of the grep documentation on your system will help. man grep , come back with questions once you've sorted the basics out and we can assist.
Additionally, show expected input and expected results from your intended commands, otherwise we are guessing.
Also, learn how to enclose code/input/output in markdown syntax by using the options menu
-exec ls -lrt {} \; fits for find.
Perhaps you want
find . -name "*" -type f -exec grep -q myexpression {} \; -exec ls -lrt {} +
Find files that contain the word "myexpression" and list them sorted, oldest first.
The second -exec is run if the first -exec was successful.
To immediately chain the second -exec the first -exec ends with a \;
The second -exec ends with + that queues arguments and finally runs one ls -ltr with the queued arguments. Only then the ls can sort.