pax*_*blo 18
你的意思是像ROT13:
pax$ echo 'hello there' | tr '[a-z]' '[n-za-m]'
uryyb gurer
pax$ echo 'hello there' | tr '[a-z]' '[n-za-m]' | tr '[a-z]' '[n-za-m]'
hello there
Run Code Online (Sandbox Code Playgroud)
对于要提供任意旋转(0到26)的更通用的解决方案,您可以使用:
#!/usr/bin/bash
dual=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
phrase='hello there'
rotat=13
newphrase=$(echo $phrase | tr "${dual:0:26}" "${dual:${rotat}:26}")
echo ${newphrase}
Run Code Online (Sandbox Code Playgroud)
如果你还想旋转大写字母,你可以使用这样的东西:
cat data.txt | tr '[a-z]' '[n-za-m]' | tr '[A-Z]' '[N-ZA-M]'
Run Code Online (Sandbox Code Playgroud)
其中 data.txt 包含您想要旋转的任何内容。
$ alpha=abcdefghijklmnopqrstuvwxyz
$ rot=3
$ sed "y/${alpha}/${alpha:$rot}${alpha::$rot}/" <<< 'foobar'
irredu
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14971 次 |
| 最近记录: |