ファイルには、mkisofs
次のような1行の文字列があります。
xorriso -as mkisofs -r -checksum_algorithm_iso sha256,sha512 -V 'Debian 12.0.0 amd64 n' -o /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/debian-12.0.0-amd64-NETINST-1.iso -checksum-list /srv/cdbuilder.debian.org/src/deb-cd/tmp/2bookwormamd64/bookworm/checksum-check -jigdo-checksum-algorithm md5 -jigdo-force-checksum /pool/ -jigdo-min-file-size 1024 -jigdo-exclude 'README*' -jigdo-exclude /doc/ -jigdo-exclude /md5sum.txt -jigdo-exclude /.disk/ -jigdo-exclude /pics/ -jigdo-exclude 'Release*' -jigdo-exclude 'Packages*' -jigdo-exclude 'Sources*' -jigdo-jigdo /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/debian-12.0.0-amd64-NETINST-1.jigdo -jigdo-template /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/debian-12.0.0-amd64-NETINST-1.template -jigdo-map Debian=/srv/cdbuilder.debian.org/src/ftp/debian/ -jigdo-exclude boot1 -J -joliet-long -cache-inodes -isohybrid-mbr syslinux/usr/lib/ISOLINUX/isohdpfx.bin -b isolinux/isolinux.bin -c isolinux/boot.cat -boot-load-size 4 -boot-info-table -no-emul-boot -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus boot1 CD1
「-jidgo」で始まるすべてのモードフラグとそのオプションを削除する必要があります。これは私が書いているスクリプトの一部です。ローカルまたは sed オプションを好むが、タスクを完了するためにリソースを増やすことができる。
各モードフラグを別々の行に配置して実行してから削除できました。
sed -i 's/-jigdo-[^-]*//' mkisofs
sed -i 's/-jigdo[^-]*//' mkisofs
このメソッドは文字列として残しても効果はありません。また、「jigdo-exclude」を部分的にのみ削除するため、2つのコマンドを作成する必要がありました。
より良いビューのために間隔をあけた各行の外観は次のとおりです。
xorriso
-as mkisofs
-r
-checksum_algorithm_iso sha256,sha512
-V 'Debian 12.0.0 amd64 n'
-o /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/debian-12.0.0-amd64-NETINST-1.iso
-checksum-list /srv/cdbuilder.debian.org/src/deb-cd/tmp/2bookwormamd64/bookworm/checksum-check
-jigdo-checksum-algorithm md5
-jigdo-force-checksum /pool/
-jigdo-min-file-size 1024
-jigdo-exclude 'README*'
-jigdo-exclude /doc/
-jigdo-exclude /md5sum.txt
-jigdo-exclude /.disk/
-jigdo-exclude /pics/
-jigdo-exclude 'Release*'
-jigdo-exclude 'Packages*'
-jigdo-exclude 'Sources*'
-jigdo-jigdo /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/debian-12.0.0-amd64-NETINST-1.jigdo
-jigdo-template /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/debian-12.0.0-amd64-NETINST-1.template
-jigdo-map Debian=/srv/cdbuilder.debian.org/src/ftp/debian/
-jigdo-exclude boot1
-J
-joliet-long
-cache-inodes
-isohybrid-mbr syslinux/usr/lib/ISOLINUX/isohdpfx.bin
-b isolinux/isolinux.bin
-c isolinux/boot.cat
-boot-load-size 4
-boot-info-table
-no-emul-boot
-eltorito-alt-boot
-e boot/grub/efi.img
-no-emul-boot
-isohybrid-gpt-basdat
-isohybrid-apm-hfsplus boot1 CD1
単一行文字列に変更すると、次のようになります。
xorriso -as mkisofs -r -checksum_algorithm_iso sha256,sha512 -V 'Debian 12.0.0 amd64 n' -o /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/debian-12.0.0-amd64-NETINST-1.iso -checksum-list /srv/cdbuilder.debian.org/src/deb-cd/tmp/2bookwormamd64/bookworm/checksum-check -J -joliet-long -cache-inodes -isohybrid-mbr syslinux/usr/lib/ISOLINUX/isohdpfx.bin -b isolinux/isolinux.bin -c isolinux/boot.cat -boot-load-size 4 -boot-info-table -no-emul-boot -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus boot1 CD1
答え1
私が見過ごしていない限り、これは私が行ったいくつかのテストと一致するようです。
sed -i -r 's/-jigdo[^ ]+ [^ ]+ //g' filename
答え2
Bing AIに質問しました。これはうまくいきます...
You can use sed to remove the mode-flags and their options that start with -jigdo. Here’s an example command that should work:
sed 's/-jigdo[^ ]* [^ ]*//g' input.txt > output.txt
Copy
This command uses a regular expression to match any text that starts with -jigdo, followed by any number of characters that are not a space, followed by a space, and then any number of characters that are not a space. This will match the mode-flag and its option. The g at the end of the command tells sed to perform this replacement globally, i.e., for all occurrences in the input line.
You can replace input.txt with the name of the file containing the original line, and output.txt with the name of the file where you want to save the modified line. If you want to perform this operation in-place, i.e., modify the original file directly, you can use the -i option:
sed -i 's/-jigdo[^ ]* [^ ]*//g' input.txt
Copy
I hope this helps! Let me know if you have any questions or if there’s anything else I can do for you.
1
of
30
Like
Dislike
Copy
Export
How do I then clear any extra spaces between the mode-flags?
You can use another sed command to remove any extra spaces between the mode-flags. Here’s an example command that should work:
sed 's/ */ /g' input.txt > output.txt
Copy
This command uses a regular expression to match any sequence of one or more spaces and replaces it with a single space. The g at the end of the command tells sed to perform this replacement globally, i.e., for all occurrences in the input line.
You can replace input.txt with the name of the file containing the line with extra spaces, and output.txt with the name of the file where you want to save the modified line. If you want to perform this operation in-place, i.e., modify the original file directly, you can use the -i option:
sed -i 's/ */ /g' input.txt
Copy
You can combine this command with the previous one to remove the -jigdo mode-flags and their options, as well as any extra spaces between the remaining mode-flags, in a single command:
sed -i 's/-jigdo[^ ]* [^ ]*//g; s/ */ /g' input.txt
Copy
I hope this helps! Let me know if you have any questions or if there’s anything else I can do for you.