다음 명령을 사용하여 모든 줄을 하나로 병합할 수 있습니다.
cat input.txt | tr -d '\n' > output.txt
하지만 아래에서 볼 수 있듯이 내 데이터는 탭과 이중 쉼표로 구분되어 있습니다.
mail._domainkey IN TXT ( "v=DKIM1; k=rsa; t=s; s=email; "
"p=MBIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AEIIBCgKCAQEAxZfSF9WkStkz1A0tbSNWAEdyHiWfenEeihvzVn8mCOx7nsUBYnEDocbDb8P0pTHS8MVNZ4jhXSwkg5mc6+NVgyZIctSogUMdD1ddGsYDfUHgT/d5tsVTzecgRtTtpdxibRyh1HY5Zmg2wxFLuCPqMPVeJHjwfKwwQHHCQtIVH+b+QvmF6hxODu73UwNUaG1cr8UkLqoQexTGoS"
"qqmGCYGKk5ImzSIoa40L1gpcSPtIWbsVTSXK1FLsovGHd7NMmEHBgv2WabpDL4BQeEfSZC0Rk5sZEaWrepiHBiTcNjhb5tyLkgxmUIW21sOA+2kmChQUwyp10qDaP5h/+s7R0arQIDAQAB" ) ; ----- DKIM key mail for domain.comtest
다음 출력을 어떻게 얻을 수 있습니까?
mail._domainkey IN TXT ( "v=DKIM1; k=rsa; t=s; s=email; p=MBIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AEIIBCgKCAQEAxZfSF9WkStkz1A0tbSNWAEdyHiWfenEeihvzVn8mCOx7nsUBYnEDocbDb8P0pTHS8MVNZ4jhXSwkg5mc6+NVgyZIctSogUMdD1ddGsYDfUHgT/d5tsVTzecgRtTtpdxibRyh1HY5Zmg2wxFLuCPqMPVeJHjwfKwwQHHCQtIVH+b+QvmF6hxODu73UwNUaG1cr8UkLqoQexTGoSqqmGCYGKk5ImzSIoa40L1gpcSPtIWbsVTSXK1FLsovGHd7NMmEHBgv2WabpDL4BQeEfSZC0Rk5sZEaWrepiHBiTcNjhb5tyLkgxmUIW21sOA+2kmChQUwyp10qDaP5h/+s7R0arQIDAQAB" ) ; ----- DKIM key mail for domain.com
답변1
cat input.txt | tr -d '\n\r\t\"' > output.txt
이것은 잘 작동할 것입니다.
답변2
탭이 아니라 공백인 것 같아요. Perl의 작동 방식:
cat input.txt | perl -00 -pe 's/"\n\s+"//g' > output.txt
답변3
GNU 사용sed
$ sed -z 's/"\n[^"]*"//g' input_file > output.txt
$ cat output.txt
mail._domainkey IN TXT ( "v=DKIM1; k=rsa; t=s; s=email; p=MBIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AEIIBCgKCAQEAxZfSF9WkStkz1A0tbSNWAEdyHiWfenEeihvzVn8mCOx7nsUBYnEDocbDb8P0pTHS8MVNZ4jhXSwkg5mc6+NVgyZIctSogUMdD1ddGsYDfUHgT/d5tsVTzecgRtTtpdxibRyh1HY5Zmg2wxFLuCPqMPVeJHjwfKwwQHHCQtIVH+b+QvmF6hxODu73UwNUaG1cr8UkLqoQexTGoSqqmGCYGKk5ImzSIoa40L1gpcSPtIWbsVTSXK1FLsovGHd7NMmEHBgv2WabpDL4BQeEfSZC0Rk5sZEaWrepiHBiTcNjhb5tyLkgxmUIW21sOA+2kmChQUwyp10qDaP5h/+s7R0arQIDAQAB" ) ; ----- DKIM key mail for domain.com