Last active
October 10, 2022 05:06
-
-
Save xbalaji/513f7300c12c0f8bc22522471922624a to your computer and use it in GitHub Desktop.
oneliners-convert-to-data-url.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple script to convert text file to data url | |
# html | |
convert2dataurl() { | |
gawk 'BEGIN {print "data:text/html,<html><head><style>p{ font-family: \"Courier New\" }</style></head><html><body><p>"} {printf "%s<br/>", $0} END {print "</body></html>"}' $1 | |
} | |
convert2dataurl data.txt | |
# plain text | |
convert2dataurl2 data.txt | |
convert2dataurl2() { | |
echo data:text/plain\;base64,$(cat $1 | base64 -w0) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment