跪求指点dos sort命令的使用
使用sort命令对test.txt里的内容进行排序,排序规则(先按a后面的数字排序,再按b后面的数字排序,再按d后面的数字排序){"a":"0031","b":"8000...
使用sort命令对 test.txt里的内容进行排序,排序规则(先按a后面的数字排序,再按b后面的数字排序,再按d后面的数字排序)
{"a":"0031","b":"800031","c":"1001","d":"20130909"}
{"a":"0031","b":"800021","c":"1001","d":"20130908"}
{"a":"0031","b":"800021","c":"1001","d":"20130909"}
{"a":"0021","b":"800001","c":"1001","d":"20130909"}
请问这个命令应该怎么写??
另外问一下,对于 已经排好序的 test1.txt,test2.txt,test3.txt怎么合并排序??? 展开
{"a":"0031","b":"800031","c":"1001","d":"20130909"}
{"a":"0031","b":"800021","c":"1001","d":"20130908"}
{"a":"0031","b":"800021","c":"1001","d":"20130909"}
{"a":"0021","b":"800001","c":"1001","d":"20130909"}
请问这个命令应该怎么写??
另外问一下,对于 已经排好序的 test1.txt,test2.txt,test3.txt怎么合并排序??? 展开
展开全部
sort命令功能没这么强大,只能从左到右(可以从第n个字符之后开始)逐个比较来排序, 要实现所提要求的排序还得用for命令, 相当于一个小“编程”, 每行前(左端)加一串满足排序要求的串,再用sort命令排序,之后还得用for 命令把加的额外串去掉,那个“合并排序”虽没怎么明白意思,恐怕也还是要用for命令处理才行,之前单个排好的序可能(对sort命令)没什么帮助作用
针对样文写个bat批处理供参考:
@echo off
(for /f "tokens=1-8 delims=:," %%a in (test.txt)do (
echo %%~b%%~d%%~h=%%a:%%b,%%c:%%d,%%e:%%f,%%g:%%h
))>temp.txt
(for /f "tokens=1* delims==" %%i in ('sort temp.txt')do echo/%%j)>new.txt
del temp.txt
pause
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询