주어진 구조의 파일을 어떻게 생성합니까?

주어진 구조의 파일을 어떻게 생성합니까?

0의 X 바이트, 숫자 7의 Y 바이트(예: 16진수 0x07, 2진수 00000111), Z 임의 바이트 및 숫자 25(16진수 0x19, 2진수 00011001)의 T 바이트가 있는 파일을 생성하려면 어떻게 해야 합니까? 마지막으로 이 파일의 크기는 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

관련 정보