我有一个包含各种 wav 文件的路径的文本文件。但是创建它们时,它们会根据字母顺序进行排序。因此路径如下
/home/wav_path/converted_Interpreter_TC_100.wav
/home/wav_path/converted_Interpreter_TC_101.wav
/home/wav_path/converted_Interpreter_TC_102.wav
/home/wav_path/converted_Interpreter_TC_103.wav
/home/wav_path/converted_Interpreter_TC_104.wav
/home/wav_path/converted_Interpreter_TC_105.wav
/home/wav_path/converted_Interpreter_TC_106.wav
/home/wav_path/converted_Interpreter_TC_107.wav
/home/wav_path/converted_Interpreter_TC_108.wav
/home/wav_path/converted_Interpreter_TC_109.wav
/home/wav_path/converted_Interpreter_TC_10.wav
/home/wav_path/converted_Interpreter_TC_110.wav
/home/wav_path/converted_Interpreter_TC_111.wav
/home/wav_path/converted_Interpreter_TC_11.wav
/home/wav_path/converted_Interpreter_TC_12.wav
/home/wav_path/converted_Interpreter_TC_13.wav
/home/wav_path/converted_Interpreter_TC_14.wav
/home/wav_path/converted_Interpreter_TC_15.wav
/home/wav_path/converted_Interpreter_TC_16.wav
/home/wav_path/converted_Interpreter_TC_17.wav
/home/wav_path/converted_Interpreter_TC_18.wav
/home/wav_path/converted_Interpreter_TC_19.wav
/home/wav_path/converted_Interpreter_TC_1.wav
/home/wav_path/converted_Interpreter_TC_20.wav
/home/wav_path/converted_Interpreter_TC_21.wav
/home/wav_path/converted_Interpreter_TC_22.wav
/home/wav_path/converted_Interpreter_TC_23.wav
/home/wav_path/converted_Interpreter_TC_24.wav
/home/wav_path/converted_Interpreter_TC_25.wav
/home/wav_path/converted_Interpreter_TC_26.wav
/home/wav_path/converted_Interpreter_TC_27.wav
/home/wav_path/converted_Interpreter_TC_28.wav
/home/wav_path/converted_Interpreter_TC_29.wav
/home/wav_path/converted_Interpreter_TC_2.wav
/home/wav_path/converted_Interpreter_TC_30.wav
/home/wav_path/converted_Interpreter_TC_31.wav
/home/wav_path/converted_Interpreter_TC_32.wav
/home/wav_path/converted_Interpreter_TC_33.wav
/home/wav_path/converted_Interpreter_TC_34.wav
/home/wav_path/converted_Interpreter_TC_35.wav
/home/wav_path/converted_Interpreter_TC_36.wav
/home/wav_path/converted_Interpreter_TC_37.wav
/home/wav_path/converted_Interpreter_TC_38.wav
/home/wav_path/converted_Interpreter_TC_39.wav
/home/wav_path/converted_Interpreter_TC_3.wav
/home/wav_path/converted_Interpreter_TC_40.wav
/home/wav_path/converted_Interpreter_TC_41.wav
/home/wav_path/converted_Interpreter_TC_42.wav
/home/wav_path/converted_Interpreter_TC_43.wav
/home/wav_path/converted_Interpreter_TC_44.wav
/home/wav_path/converted_Interpreter_TC_45.wav
/home/wav_path/converted_Interpreter_TC_46.wav
/home/wav_path/converted_Interpreter_TC_47.wav
/home/wav_path/converted_Interpreter_TC_48.wav
/home/wav_path/converted_Interpreter_TC_49.wav
/home/wav_path/converted_Interpreter_TC_4.wav
/home/wav_path/converted_Interpreter_TC_50.wav
/home/wav_path/converted_Interpreter_TC_51.wav
/home/wav_path/converted_Interpreter_TC_52.wav
/home/wav_path/converted_Interpreter_TC_53.wav
/home/wav_path/converted_Interpreter_TC_54.wav
/home/wav_path/converted_Interpreter_TC_55.wav
/home/wav_path/converted_Interpreter_TC_56.wav
/home/wav_path/converted_Interpreter_TC_57.wav
/home/wav_path/converted_Interpreter_TC_58.wav
/home/wav_path/converted_Interpreter_TC_59.wav
/home/wav_path/converted_Interpreter_TC_5.wav
/home/wav_path/converted_Interpreter_TC_60.wav
/home/wav_path/converted_Interpreter_TC_61.wav
/home/wav_path/converted_Interpreter_TC_62.wav
/home/wav_path/converted_Interpreter_TC_63.wav
/home/wav_path/converted_Interpreter_TC_64.wav
/home/wav_path/converted_Interpreter_TC_65.wav
/home/wav_path/converted_Interpreter_TC_66.wav
/home/wav_path/converted_Interpreter_TC_67.wav
/home/wav_path/converted_Interpreter_TC_68.wav
/home/wav_path/converted_Interpreter_TC_69.wav
/home/wav_path/converted_Interpreter_TC_6.wav
/home/wav_path/converted_Interpreter_TC_70.wav
/home/wav_path/converted_Interpreter_TC_71.wav
/home/wav_path/converted_Interpreter_TC_72.wav
/home/wav_path/converted_Interpreter_TC_73.wav
/home/wav_path/converted_Interpreter_TC_74.wav
/home/wav_path/converted_Interpreter_TC_75.wav
/home/wav_path/converted_Interpreter_TC_76.wav
/home/wav_path/converted_Interpreter_TC_77.wav
/home/wav_path/converted_Interpreter_TC_78.wav
/home/wav_path/converted_Interpreter_TC_79.wav
/home/wav_path/converted_Interpreter_TC_7.wav
/home/wav_path/converted_Interpreter_TC_80.wav
/home/wav_path/converted_Interpreter_TC_81.wav
/home/wav_path/converted_Interpreter_TC_82.wav
/home/wav_path/converted_Interpreter_TC_83.wav
/home/wav_path/converted_Interpreter_TC_84.wav
/home/wav_path/converted_Interpreter_TC_85.wav
/home/wav_path/converted_Interpreter_TC_86.wav
/home/wav_path/converted_Interpreter_TC_87.wav
/home/wav_path/converted_Interpreter_TC_88.wav
/home/wav_path/converted_Interpreter_TC_89.wav
/home/wav_path/converted_Interpreter_TC_8.wav
/home/wav_path/converted_Interpreter_TC_90.wav
/home/wav_path/converted_Interpreter_TC_91.wav
/home/wav_path/converted_Interpreter_TC_92.wav
/home/wav_path/converted_Interpreter_TC_93.wav
/home/wav_path/converted_Interpreter_TC_94.wav
/home/wav_path/converted_Interpreter_TC_95.wav
/home/wav_path/converted_Interpreter_TC_98.wav
/home/wav_path/converted_Interpreter_TC_99.wav
/home/wav_path/converted_Interpreter_TC_9.wav
我希望它们根据 TC 后的数字进行排序,这样它们就可以像这样
/home/wav_path/converted_Interpreter_TC_1.wav
/home/wav_path/converted_Interpreter_TC_2.wav
/home/wav_path/converted_Interpreter_TC_3.wav
/home/wav_path/converted_Interpreter_TC_4.wav
我尝试过使用sort
,sort -n
但都不起作用。有人能帮我怎么做吗?
答案1
您可能希望将下划线字符指定_
为字段分隔符-t '_'
,然后按第五个字段按-k 5
数字方式排序-n
,如下所示:
sort -n -t '_' -k 5,5 file