我的文本文件包含以下内容:
@_.5_sh
@handa12247
@lshydymhmwd
@ahmr0784
@f7j.i
@carameljeddah
@lnqm_iii2
@raghad.ayman.524
@asfhfdfgt4355
@kuw871
@nouralhuda_muhammad
@gogo56817gma
@kaald10000
@sal_0221
@kaled_24009165
@km_kn124
@princess.hana89
@fulefulemm
@norah.0._
@ommajed965
@lam3aastar
@alimarar265
@klthmlmdy
@anas.sasan55
@s.m_b.b
@asnosy_almgrhe_
@norh7132
@880ali7
@tv.creativity
@ksakking3
我想对每行中的每5个用户进行排序。
@_.5_sh @handa12247 @lshydymhmwd @ahmr0784 @f7j.i
@carameljeddah @lnqm_iii2 @raghad.ayman.524 @asfhfdfgt4355 @kuw871
@nouralhuda_muhammad @gogo56817gma @kaald10000 @sal_0221 @kaled_24009165
@km_kn124 @princess.hana89 @fulefulemm @norah.0._ @ommajed965
@lam3aastar @alimarar265 @klthmlmdy @anas.sasan55 @s.m_b.b
@asnosy_almgrhe_ @norh7132 @880ali7 @tv.creativity @ksakking3
我尝试过seq和awk,但尝试失败。我希望有人能帮助我进行这种排序。
答案 0 :(得分:3)
使用awk
awk 'ORS=NR%5?FS:RS' file
@_.5_sh @handa12247 @lshydymhmwd @ahmr0784 @f7j.i
@carameljeddah @lnqm_iii2 @raghad.ayman.524 @asfhfdfgt4355 @kuw871
@nouralhuda_muhammad @gogo56817gma @kaald10000 @sal_0221 @kaled_24009165
@km_kn124 @princess.hana89 @fulefulemm @norah.0._ @ommajed965
@lam3aastar @alimarar265 @klthmlmdy @anas.sasan55 @s.m_b.b
@asnosy_almgrhe_ @norh7132 @880ali7 @tv.creativity @ksakking3
每5行更改输出记录选择器
编辑:这不适用于dos格式文件,因此请在dos2unix yourfile
之前运行awk