cpp 대용량 바이너리 앞부분 제거를 하고 싶습니다.

ddmaru의 이미지

cpp 대용량 바이너리 앞부분 제거를 하고 싶습니다.

truncate 으로처하려 했는대...

원본 바이너리파일 내용 "123456789"
결과 바이너리파일 내용 "12345678"

이걸 사용하면 파일 뒷부분이 제거 되더군요!

제가찾고 있는것은 앞부분을 제거 했으면 합니다.

원본 바이너리파일 내용 "123456789"
결과 바이너리파일 내용 "23456789"

파일이 크다보니 전부 리드하여 다시 저장하기엔 시간이 너무 오래 걸립니다.

해결방안이 있을까요~? 고수님들의 조언 부탁드립니다.

swish95의 이미지

한줄짜리 bin 파일이라면 ...
1. cut 을 이용하여 처음 1byte 를 추출..
2. xdd 로 파일 내용 출력 후 파이프 전달
3. 2의 내용중 sed 로 ^1결과 를 공백으로 치환
4. 결과를 파일로 저장

여러줄이라면 첫줄만 위의 내용을 수행하고 나머지는 그대로 쓰면 되지 않을까요?

------------------------------------------------------------
ProgrammingHolic

ddmaru의 이미지

예시로 1줄 처리로 적어노았는대 실상은 여러줄이다보니 해당 방법은 힘들것같아요
의견 감사합니다.

ymir의 이미지

어차피 파일을 읽어서 원하는 부분부터 새로 써야 할 것 같은데요..?

$ fallocate -l 1G a.bin
$ time dd if=a.bin of=a-dd.bin bs=1M skip=100 iflag=skip_bytes
1023+1 records in
1023+1 records out
1073741724 bytes (1.1 GB, 1.0 GiB) copied, 0.69023 s, 1.6 GB/s
 
real    0m0.694s
user    0m0.009s
sys     0m0.624s
 
$ time tail -c +101 a.bin > a-tail.bin
 
real    0m0.943s
user    0m0.122s
sys     0m0.699s
 
$ ls -al a*.bin
-rw-rw-r-- 1 ymir ymir 1073741824 1122 13:35 a.bin
-rw-rw-r-- 1 ymir ymir 1073741724 1122 13:36 a-dd.bin
-rw-rw-r-- 1 ymir ymir 1073741724 1122 13:38 a-tail.bin

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

ddmaru의 이미지

읽어서 다시 쓰는것 뿐이겠죠? ㅠ
의견 감사합니다!!

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.