Z 형식으로 되어있는것을 gz 압축형식으로 바꿀수 있나요?

류호태의 이미지

학술 연구 하는데
형식이 a.Z 형식으로 되어있습니다.

그런데 이걸 a.gz 즉 gzip 형식으로 해야만 application에서 돌아갑니다.

이 파일이 폴더단위(한폴더에 5개이상)로 수천개 가 되어서 수작업으로 정말 할수 없습니다.

이걸 쉘로 쉽게 Z형식을 압축풀고 푼 파일을 gz 파일로 압축할수 있는 스크립터는 없을까요?

익명사용자(cshwang)의 이미지

시험해보고 사용하세요.
find . -name "*\.Z" -a -type f -print -exec uncompress {} \; | sed -e 's:\(.*\)\.Z:\1:' | xargs gzip

esrevinu의 이미지

#!/bin/sh
for filename in $*
do
    echo -n changing $filename to ${filename%.*}.gz ...
    uncompress -c $filename | gzip > ${filename%.*}.gz
    echo done.
done

test.sh 이란 파일이름으로 저장하셨다면 ./test.sh *.Z 하시면 되겠죠.

흑흑, 여러 폴더에 있는 거군요. 벌써 누군가 올리셨네. 그래도 그냥 둡니다.

--
foldl (flip (:)) [] "universe"

aero의 이미지

for i in `find . -type f -name "*\.Z"`; do uncompress $i && gzip ${i%\.Z} ; done

테스트 해봤습니다.

세이군의 이미지

znew라는 프로그램이 있습니다. 인수로 .Z파일명을 주면 알아서 .gz파일로 바꿔줍니다.
BASH 스크립트인데 esrevinu 님이 적어주신 것과 비슷한 내용을 가지고 있습니다.

find . -type f -name "*.Z" | xargs znew
이 정도면 될 것 같기도 하고....

적당히 파일 2~3개 정도 있는 디렉토리에서 해보시고 잘 되면 전체 디렉토리 대상으로 다시 하시면 됩니다.
한 걸음 더 가까이

류호태의 이미지

정말 감사합니다.. 쉘 스크립터로 하니 이렇게 쉽게 되다니 노가다 해방 되었습니;다....정말로 도와주신분들 감사합니다..

바로 해결 되어버렷네요... 정말로 감사합니다..

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.