pug*_*soy 3 windows command-line flip
是否有程序或 CMD 命令可以简单地反转或翻转文件的所有字节?例如,如果我有一个文本文件(作为一个简单的例子)说“你好,世界!”,程序/命令会将它翻转为“!dlrow,olleH”。
所以是的,有没有办法做到这一点?我是一名程序员,并且知道为此编写自己的程序是微不足道的,但是如果已经有可以做到的事情,我宁愿不去麻烦。批处理脚本也可以。
powershell $s='Hello, world!';$s[-1..-($s.length)]-join''
Run Code Online (Sandbox Code Playgroud)
文件:
方式一:
powershell $f=[IO.File]::ReadAllBytes('.\file.txt');$t=[Text.Encoding]::ASCII.GetString($f);$t[-1..-($t.length)]-join''
Run Code Online (Sandbox Code Playgroud)
方式2:
powershell [void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');$s=gc .\file.txt;[Microsoft.VisualBasic.Strings]::StrReverse($s)
Run Code Online (Sandbox Code Playgroud)
字节反转:
减缓:
powershell [byte[]]$b=gc '.\file.bin' -En byte;[array]::Reverse($b);[IO.File]::WriteAllBytes('.\Reverse.bin',$b)
Run Code Online (Sandbox Code Playgroud)
快速地:
powershell [byte[]]$b=[IO.File]::ReadAllBytes('.\file.bin');[array]::Reverse($b);[IO.File]::WriteAllBytes('.\Reverse.bin',$b)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2386 次 |
| 最近记录: |