dd 명령에서 탐색과 건너뛰기의 차이점은 무엇입니까?

dd 명령에서 탐색과 건너뛰기의 차이점은 무엇입니까?

디스크에서 데이터를 읽으려고 하는데 dd각 요청을 무작위로 수행하고 디스크의 읽기 작업 대기 시간을 확인하는 명령을 원합니다. 이 두 작업을 "찾기"와 "건너뛰기"를 사용했는데 효과가 있습니까?

dd if=/dev/rdsk/c2t5000CCA0284F36A4d0 skip=10  of=/dev/null bs=4k count=1024000
1024000+0 records in
1024000+0 records out
4194304000 bytes (4.2 GB) copied, 51.0287 s, 82.2 MB/s


dd if=/dev/rdsk/c2t5000CCA0284F36A4d0  seek=10  of=/dev/null bs=4k count=1024000
1024000+0 records in
1024000+0 records out
4194304000 bytes (4.2 GB) copied, 51.364 s, 81.7 MB/s

누군가 디스크에서 데이터를 읽는 새로운 방법을 제안할 수 있습니까?

답변1

skipiseek(일부 구현에서도 호출됨 dd)은 입력 스트림의 현재 포인터를 이동하는 동시에 seek출력 스트림의 현재 포인터를 이동합니다.

따라서 를 사용하면 skip입력 스트림 시작 부분의 일부 데이터를 무시할 수 있습니다.

일반적으로 (항상 그런 것은 아님) 출력 스트림의 시작 부분에 있는 일부 데이터를 보존하기 위해 seek와 함께 사용됩니다 .conv=notrunc

답변2

매뉴얼 페이지에서dd

seek=BLOCKS
skip BLOCKS obs-sized blocks at start of output
skip=BLOCKS
skip BLOCKS ibs-sized blocks at start of input

이는 다음과 같이 다시 작성할 수 있습니다.

seek파일 시작 부분에서 n 블록을 건너뜁니다 output.

skip파일 시작 부분에서 n 블록을 건너뜁니다 input.

답변3

다음 예제에서는 먼저 입력 파일과 출력 파일을 준비한 다음 입력의 일부를 출력 파일의 일부로 복사합니다.

echo     "IGNORE:My Dear Friend:IGNORE"      > infile
echo "Keep this, OVERWRITE THIS, keep this." > outfile
cat infile
cat outfile
echo
dd status=none \
   bs=1 \
   if=infile \
   skip=7 \
   count=14 \
   of=outfile \
   conv=notrunc \
   seek=11

cat outfile

dd의 매개변수는 다음과 같습니다.

status=none  Don't output final statistics as dd usually does - would disturb the demo
bs=1         All the following numbers are counts of bytes -- i.e., 1-byte blocks.
if=infile    The input file
skip=7       Ignore the first 7 bytes of input (skip "IGNORE:")
count=14     Transfer 14 bytes from input to output
of=outfile   What file to write into
conv=notrunc Don't delete old contents of the output file before writing.
seek=11      Don't overwrite the first 11 bytes of the output file
             i.e., leave them in place and start writing after them

스크립트를 실행한 결과는 다음과 같습니다.

IGNORE:My Dear Friend:IGNORE
Keep this, OVERWRITE THIS, keep this.

Keep this, My Dear Friend, keep this.

"skip"과 "seek"의 값이 바뀌면 어떻게 되나요? dd는 입력의 잘못된 부분을 복사하고 출력 파일의 잘못된 부분을 덮어씁니다.

Keep thear Friend:IGNTHIS, keep this.

관련 정보