Re: remote ssh awk!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is harder, without source sample data to also work with, but, I believe the following would work:
ssh $id@$ip "cat /dog/aaa.dat | awk \'\!a[\$0]++\' > /dog/aaa.dat_tmp"

Backslashes before both of the single quotes, before the exclamation mark (processed by the bash shell affecting history), and before the dollarsign (processed by the bash shell, as an environment variable).
Another option might be to escape (i.e. place a backslash) before the open and close brackets ([ ]).



From: bruce <badouglas@xxxxxxxxx>
To: Community support for Fedora users <users@xxxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, June 20, 2017 10:20 AM
Subject: remote ssh awk!

Hey...

Curious as to how to get the following to work remotely over SSH. The
cmd is used to remove redundant lines, while maintaining order in the
output file.

The following works if I insert it in the remote term.
  cat /dog/aaa.dat | awk '!a[$0]++' > /dog/aaa.dat_tmp


However I'm unable to get the cmd to work via SSH from the local to
the remote. I've tried the following...
ssh  crawl_user@67.205.11.111  cat /dog/aaa.dat | awk '!a[$0]++' >
/dog/aaa.dat_tmp
ssh  crawl_user@67.205.11.111 ' cat /dog/aaa.dat | awk '!a[$0]++' >
/dog/aaa.dat_tmp '
ssh  crawl_user@67.205.11.111 " cat /dog/aaa.dat | awk '!a[$0]++' >
/dog/aaa.dat_tmp "
ssh  crawl_user@67.205.11.111 ' cat /dog/aaa.dat | awk '\!a[$0]++' >
/dog/aaa.dat_tmp '
ssh  crawl_user@67.205.11.111 " cat /dog/aaa.dat | awk '\!a[$0]++' >
/dog/aaa.dat_tmp "

ssh  crawl_user@67.205.11.111 ' cat /dog/aaa.dat | awk '"\!"a[$0]++' >
/dog/aaa.dat_tmp '
ssh  crawl_user@67.205.11.111 " cat /dog/aaa.dat | awk '"\!"a[$0]++' >
/dog/aaa.dat_tmp "


In some cases, the cmd returns -- bash: !a[$0]++: event not found


In the case
ssh  crawl_user@67.205.11.111 " cat /dog/aaa.dat | awk '\!a[$0]++' >
/dog/aaa.dat_tmp "
  the return is:
    awk: \!a[bash]++
    awk: ^ backslash not last character on line

The escapsed cmds seem to work, but in reality, only generates the 1st
line in the file!
  ssh  crawl_user@67.205.11.111 " cat /dog/aaa.dat | awk '"\!"a[$0]++'
> /dog/aaa.dat_tmp "


Thoughts/comments???

Thanks
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx


_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux