Wednesday, November 3, 2021

[SOLVED] How to use SSH to run a local awk script on a remote machine with the remote file name as parameter?

Issue

I know that I can run a local bash script on a remote host via ssh per this other question. But what about running a local awk script that receives a file as a parameter?

I've tried something like this but no luck:

ssh myuser@machine 'awk -s' < awk -f my_local_awk_script.awk "/remote/path/remote_file.txt"

Solution

Can this achieve what you expected :

ssh myuser@machine awk -s -f /dev/stdin /remote/path/remote_file.txt < my_local_awk_script.awk


Answered By - Philippe