2 ms·
If provide a text-processing problem I will try to provide a solution. Meanwhile here is one. Insert stdin or a src file at the top of a dst file. test
by 1vuio0pswjnm7 4y ago
If provide a text-processing problem I will try to provide a solution.
Meanwhile here is one. Insert stdin or a src file at the top of a dst file.
test ! -h $1||exec echo $0: error: symlink
case $# in :)
;;1) x=$(sed -n '$=' $1)
test $x -gt 1||exec echo usage: $0 dst src
sed -i -e1r/dev/stdin -e1N $1
;;2) printf '0r '$2'\nwq\n'|ed -s $1
esac
For example,
1.sh 1.c < 1.h
echo 93.184.216.34 example.com|1.sh /etc/hosts
or
1.sh 1.c 1.h
1.sh /etc/hosts map-ip-host.txt
How is this done in Python.
- 1vuio0pswjnm7 4y agoHere is another variation that does not used "sed -i". It uses a favourite hex editor called ired. test ! -h $1||exec echo $0: error: symlink case $# in :) ;;1) x=$(sed -n '$=' $1) test $x -gt 1||exec echo usage: $0 dst src od -tx1 -An|sed 's/^/w /'|ired -n $1 /dev/stdin ;;2) printf '0r '$2'\nwq\n'|ed -s $1 esac