次のコマンドを使用して、すべての行を1つにマージできます。
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