shell

Outputting Here Document Text to Remote File via SSH

In Bash language command line on Linux PC/server, this article introduces how to output here document text to a remote file via SSH.

Shou Arisaka
1 min read
Oct 23, 2025

In Bash language command line on Linux PC/server, this article introduces how to output here document text to a remote file via SSH.

ubuntupc "cat <<< \"\$(</dev/stdin)\" >> ~/tmp.txt" <<< "hogehoge"

# or

ubuntupc "cat <<< \"\$(</dev/stdin)\" >> ~/tmp.txt" <<< "$( cat << 'EOT'
hogehoge
EOT
)"
alias ubuntupc='ssh -v -X -L 8001:localhost:80     -L 4001:localhost:4001 -L 4002:localhost:4002 -L 4003:localhost:4003 -L 4004:localhost:4004 -L 4005:localhost:4005 -L 4006:localhost:4006 -L 4007:localhost:4007 -L 4008:localhost:4008     -R 52698:localhost:52698 [email protected]'

Usage Example


sendfunction(){

  : send locally defined functions or aliases to remote machine via ssh
  : e.g. sendfunction sharefile

[[ -z "${1:-isodate}" ]] && { error Empty argment[s] ; return 1 ; }

ubuntupc "cat <<< \"\$(</dev/stdin)\" >> ~/.bashrc" <<< "$( cat << EOT
$( types "${1:-isodate}" )
EOT
)"

}

Share this article

Shou Arisaka Oct 23, 2025

๐Ÿ”— Copy Links