awk를 통해 여러 줄의 레코드를 분할하는 방법(예: 다음 파일):
027,027,0,3,,1,0,1,1,0,0,0,0,0,0,0,0,6,1,,1.211100,1,2015-08-03,2015-07-04,,2015-11-01,0,0,2015-11-01,1,1,,0,0,0,0,0,131,0,0,0,0,0,2015-06-01,10000000000000000000,,
136,136,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,1,1,,0.350000,1,2015-08-17,2015-07-18,,2015-11-15,0,0,2015-11-15,0,0,,0,0,0,0,0,131,0,0,0,0,0,2012-11-20,10000000000000000000,,
633,633,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,3,1,,3.125300,1,2015-08-31,2015-08-01,,2015-11-29,0,0,2015-11-29,0,0,,0,0,0,0,0,131,0,0,0,0,0,2014-12-12,10000000000000000000,,
802,802,0,0,,1,0,1,1,0,1,0,0,0,0,0,0,7,1,,0.060000,1,2015-08-05,2015-07-06,,2015-11-03,0,0,2015-08-05,1,1,,0,0,0,0,0,131,0,0,0,0,0,2014-08-10,10000000000000000000,,
원하는 출력은 다음과 RS
같아야 "*"
합니다.
027,027,0,3,,1,0,1,1,0,0,0,0,0,0,0,0,6,1,,1.211100,1,2015-08-03,2015-07-04,,2015-11-01,0,0,2015-11-01,1,1,,0,0,0,0,0,131,0,0,0,0,0,2015-06-01,10000000000000000000,,
********************************************************************************************************************************************************************
136,136,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,1,1,,0.350000,1,2015-08-17,2015-07-18,,2015-11-15,0,0,2015-11-15,0,0,,0,0,0,0,0,131,0,0,0,0,0,2012-11-20,10000000000000000000,,
*******************************************************************************************************************************************************************
633,633,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,3,1,,3.125300,1,2015-08-31,2015-08-01,,2015-11-29,0,0,2015-11-29,0,0,,0,0,0,0,0,131,0,0,0,0,0,2014-12-12,10000000000000000000,,
*******************************************************************************************************************************************************************
802,802,0,0,,1,0,1,1,0,1,0,0,0,0,0,0,7,1,,0.060000,1,2015-08-05,2015-07-06,,2015-11-03,0,0,2015-08-05,1,1,,0,0,0,0,0,131,0,0,0,0,0,2014-08-10,10000000000000000000,,
*******************************************************************************************************************************************************************
여러 코드 생성을 사용해 보았 {RS="*"}
으나 성공하지 못했습니다.
답변1
한 가지 방법은 다음과 같습니다.
$ v='\n*******************************************************************************************************************************************************************\n'
$ awk -v ORS="$v" '{print;}' file
027,027,0,3,,1,0,1,1,0,0,0,0,0,0,0,0,6,1,,1.211100,1,2015-08-03,2015-07-04,,2015-11-01,0,0,2015-11-01,1,1,,0,0,0,0,0,131,0,0,0,0,0,2015-06-01,10000000000000000000,,
*******************************************************************************************************************************************************************
136,136,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,1,1,,0.350000,1,2015-08-17,2015-07-18,,2015-11-15,0,0,2015-11-15,0,0,,0,0,0,0,0,131,0,0,0,0,0,2012-11-20,10000000000000000000,,
*******************************************************************************************************************************************************************
633,633,0,0,,1,0,1,1,0,0,0,0,0,0,0,0,3,1,,3.125300,1,2015-08-31,2015-08-01,,2015-11-29,0,0,2015-11-29,0,0,,0,0,0,0,0,131,0,0,0,0,0,2014-12-12,10000000000000000000,,
*******************************************************************************************************************************************************************
802,802,0,0,,1,0,1,1,0,1,0,0,0,0,0,0,7,1,,0.060000,1,2015-08-05,2015-07-06,,2015-11-03,0,0,2015-08-05,1,1,,0,0,0,0,0,131,0,0,0,0,0,2014-08-10,10000000000000000000,,
*******************************************************************************************************************************************************************
ORS를 명시적으로 설정하지 않고 동일한 효과를 얻는 또 다른 방법은 다음과 같습니다.
awk '{print;} {for(i=1;i<=length($0);i++)printf "*";print"";}' file