Answer the question
In order to leave comments, you need to log in
How to correctly assign Cyrillic to a variable in bash?
Hello. Those who work a lot in the Linux console and use Twitter may have heard/used the console utility for sending tweets -- twidge. The utility works flawlessly and honestly sends tweets to an authorized account, if not for one "but". In the usual case, the utility picks up one line shorter than 140 characters without a line break Привет мир! | twidge update
. Actually, everything would be fine, but the idea came to my mind (probably not for me first) to enter tweets not by hand, but to use another Linux console utility for this - fortune , which produces a random quote. fortune | twidge update
, but as it turned out, when the line is moved, the tweet is considered finished and sent to the server. And fortunes usually consist of 2 or 3 lines. On the linux forum, they suggested this form of entry
fortune -sn140 | tr -s '[:space:]' ' ' | twidge update
Now the fortunes are not cut, because. Line breaks have been removed, but formatting is completely lost, which can ruin fortune, for example, with poetry. Having poked a finger into the sky a little, I came to the conclusion that you can try to output fortunes first to a file on your hard drive, and then through cat
assign the contents of the file to a variable, and feed the variable twidge update
. #!/bin/bash
config_file=$(cat test)
twidge update "$config_file"
test
and scored the following text there:bla
bla
Hello world!
бла
бла
Привет Мир!
twidge: Enum.toEnum{Word8}: tag (1073) is outside of bounds (0,255)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question