iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🎃

[Bash] Output characters in a specified range of code points

に公開

Let's try outputting "あいうえお". As preparation, let's generate integers from 0x3042 to 0x304A.

echo 304{{2..8..2},{A..A}}
3042 3044 3046 3048 304A

Next, let's try outputting Unicode escape sequences using printf.

printf '%b ' \\\\U304{{2..8..2},{A..A}}; echo
 

Next, let's try generating all the code points in the Hiragana block. The range is from 0x3041 to 0x309F.

echo 30{4..9}{{0..9},{A..F}}

Let's try outputting the characters. Since there are many, we will use paste to fit them within a certain width.

printf %b\\n \\U30{4..9}{{0..9},{A..F}} | paste -d\  -{,,,}{,,,}

Now let's work with emojis. The range is 1F600–1F64F.

echo 1F6{0..4}{{0..9},{A..F}}

Let's try displaying all of them in the same way.

printf %b\\n \\U1F6{0..4}{{0..9},{A..F}} | paste -d\  -{,,,}{,,,}

Discussion