
다음과 같은 65,000줄의 파일이 있습니다.
Mumford & Sons,Wilder Mind (Deluxe),Believe - Live,02 Oct 2016 10:25
Mumford & Sons,Wilder Mind (Deluxe),Tompkins Square Park,02 Oct 2016 10:19
Mumford & Sons,Wilder Mind (Deluxe),Believe,02 Oct 2016 10:16
Bon Iver,22 A Million,00000 Million,02 Oct 2016 10:06
Bon Iver,22 A Million,____45_____,02 Oct 2016 10:03
Bon Iver,22 A Million,8 (circle),02 Oct 2016 09:58
나는 많은 노력을 해왔지만 끝내지 못했습니다. 다음과 같이 표시되어야 합니다.
Mumford & Sons,Believe - Live,Wilder Mind (Deluxe),02 Oct 2016 10:25
두 번째 열이 세 번째 열로 전환됩니다. 이를 수행하는 간단한 방법이 있습니까?
답변1
이것이 작동할까요?
awk -F, '{A=$3; $3=$2; $2=A; print}' OFS=, yourfile
기본적으로 열을 로 구분하고 본문이 두 번째 열을 세 번째 열로 전환한 다음 수정된 줄을 사용한다고 -F
말합니다 .,
print
답변2
sed -r 's/(.*),(.*),(.*),(.*)/\1,\3,\2,\4/' file
Mumford & Sons,Believe - Live,Wilder Mind (Deluxe),02 Oct 2016 10:25
Mumford & Sons,Tompkins Square Park,Wilder Mind (Deluxe),02 Oct 2016 10:19
Mumford & Sons,Believe,Wilder Mind (Deluxe),02 Oct 2016 10:16
Bon Iver,00000 Million,22 A Million,02 Oct 2016 10:06
Bon Iver,____45_____,22 A Million,02 Oct 2016 10:03
Bon Iver,8 (circle),22 A Million,02 Oct 2016 09:58