vla*_*iov 2 sorting file batch-file
我想知道是否有可能按列对文本文件进行排序.例如
我有这样aux1.txt
的行
Name SecondName Grade
Run Code Online (Sandbox Code Playgroud)
在shell中,我可以做到这一点
sort -r -k 3 aux1
Run Code Online (Sandbox Code Playgroud)
它按第3列(等级)对文件进行排序.
批量生产
sort /+3 < aux1.txt
Run Code Online (Sandbox Code Playgroud)
在第3个字母后对文件进行排序.
我阅读了批处理的分类手册但没有结果.
您可以使用批处理文件编写自己的排序包装器.
您只需将列重新排序为临时文件,对其进行
排序并将其排序.(几乎显而易见)
REM *** Get the desired colum and place it as first column in the temporary file
setlocal DisableDelayedExpansion
(
for /F "tokens=1-3 delims= " %%A in (aux1.txt) DO (
set "par1=%%A"
set "par2=%%B"
set "par3=%%C"
setlocal EnableDelayedExpansion
echo(!par2! !par1! !par2! !par3!
endlocal
)
) > aux1.txt.tmp
REM ** Now sort the first colum, but echo only the rest of the line
for /F "usebackq tokens=1,* delims= " %%A in (`sort /r aux1.txt.tmp`) DO (
echo(%%B
)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6674 次 |
最近记录: |