指定された構造を持つファイルを作成するにはどうすればよいですか?

指定された構造を持つファイルを作成するにはどうすればよいですか?

X バイトが 0、Y バイトが数値 7 (つまり、16 進数では 0x07、2 進数では 00000111)、Z バイトがランダム、T バイトが数値 25 (16 進数では 0x19、2 進数では 00011001) のファイルを作成するにはどうすればよいですか。最終的に、このファイルのサイズは X+Y+Z+T バイトになります。

答え1

ソフトウェア センターから「ghex」をインストールします。

ターミナルに移動して を実行しますtouch hexfile

ghex を開き、次に 'hexfile' を開きます。

挿入キーを押して、必要なバイトを入力します。

保存。


このようなものをファイルに保存し、変数を変更し (指示どおりに)、実行可能にして ( chmod +x filename)、実行できる可能性があります./filename

#!/bin/bash
#(C) 2011 Erik B. Andersen This script is licensed under the latest non-draft
#version of the AGPL as published by the Free Software Foundation (currently 
#at http://www.gnu.org/licenses/) .
# Set the following four variables.
X=
Y=
Z=
T=
#######Don't need to change anything past here.
y=0
t=0
head -c $X /dev/zero >> structurefile
while [ $y -lt $Y ]; do echo -n -e "\x07"; y=$(($y+1)); done >> structurefile
head -c $Z /dev/urandom >> structurefile
while [ $t -lt $T ]; do echo -n -e "\x19"; t=$(($t+1)); done >> structurefile

関連情報