I'd like to emulate

ls -tlra | grep <search term>

in Wolfram. I have tried

  RunProcess[{"ls", "-tlra", "|", "grep", <searchTerm>}, "StandardOutput"]

which doesn't seem to work. Is there a way to use the "pipe" operator when shelling out commands in Wolfram?

  • 1
    $\begingroup$ Try prepending "bash","-c" as I show in this answer. $\endgroup$ – Tim Laska Sep 10 '19 at 16:35

For example:

RunProcess[{"bash", "-c", 
  "ls -ltr | grep wolf "}, "StandardOutput", 
 ProcessDirectory -> $InstallationDirectory]
(* "-rwxr-x---+ 1 Administrators None  551360 Apr  8 09:51 \
-rwxr-x---+ 1 Administrators None 2390464 Apr  8 09:52 \
wolframscript.exe *)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.