how can I extract multiple gzip files in directory and subdirectories?
I have tried both gzip
and gunzip
commands but I get either
gunzip *.gz
gzip: invalid option -- 'Y'
gunzip -S-1800-01-01-000000-g01.h5.gz
gzip: compressed data not read
from a terminal. Use -f to force decompression. For help, type: gzip -h
If I try the -f
option it takes a very long time to work on one single file and the command is not executed successfully. Am I missing something?
gzip
add a comment |
I have tried both gzip
and gunzip
commands but I get either
gunzip *.gz
gzip: invalid option -- 'Y'
gunzip -S-1800-01-01-000000-g01.h5.gz
gzip: compressed data not read
from a terminal. Use -f to force decompression. For help, type: gzip -h
If I try the -f
option it takes a very long time to work on one single file and the command is not executed successfully. Am I missing something?
gzip
1
Does the directory contain .gz files whose names start with hyphens, such as-Y.something.gz
? If so you may need to use the Gnu--
flag to ensure that they are treated as filenames rather than options i.e.gunzip -- *.gz
– steeldriver
Nov 3 '15 at 13:29
@steeldriver yes I do have a few files starting with -
– Herman Toothrot
Nov 3 '15 at 13:47
that caused at least one of the two problems.
– Herman Toothrot
Nov 3 '15 at 14:25
add a comment |
I have tried both gzip
and gunzip
commands but I get either
gunzip *.gz
gzip: invalid option -- 'Y'
gunzip -S-1800-01-01-000000-g01.h5.gz
gzip: compressed data not read
from a terminal. Use -f to force decompression. For help, type: gzip -h
If I try the -f
option it takes a very long time to work on one single file and the command is not executed successfully. Am I missing something?
gzip
I have tried both gzip
and gunzip
commands but I get either
gunzip *.gz
gzip: invalid option -- 'Y'
gunzip -S-1800-01-01-000000-g01.h5.gz
gzip: compressed data not read
from a terminal. Use -f to force decompression. For help, type: gzip -h
If I try the -f
option it takes a very long time to work on one single file and the command is not executed successfully. Am I missing something?
gzip
gzip
edited Nov 3 '15 at 13:01
pl_rock
7,28542835
7,28542835
asked Nov 3 '15 at 12:33
Herman ToothrotHerman Toothrot
203239
203239
1
Does the directory contain .gz files whose names start with hyphens, such as-Y.something.gz
? If so you may need to use the Gnu--
flag to ensure that they are treated as filenames rather than options i.e.gunzip -- *.gz
– steeldriver
Nov 3 '15 at 13:29
@steeldriver yes I do have a few files starting with -
– Herman Toothrot
Nov 3 '15 at 13:47
that caused at least one of the two problems.
– Herman Toothrot
Nov 3 '15 at 14:25
add a comment |
1
Does the directory contain .gz files whose names start with hyphens, such as-Y.something.gz
? If so you may need to use the Gnu--
flag to ensure that they are treated as filenames rather than options i.e.gunzip -- *.gz
– steeldriver
Nov 3 '15 at 13:29
@steeldriver yes I do have a few files starting with -
– Herman Toothrot
Nov 3 '15 at 13:47
that caused at least one of the two problems.
– Herman Toothrot
Nov 3 '15 at 14:25
1
1
Does the directory contain .gz files whose names start with hyphens, such as
-Y.something.gz
? If so you may need to use the Gnu --
flag to ensure that they are treated as filenames rather than options i.e. gunzip -- *.gz
– steeldriver
Nov 3 '15 at 13:29
Does the directory contain .gz files whose names start with hyphens, such as
-Y.something.gz
? If so you may need to use the Gnu --
flag to ensure that they are treated as filenames rather than options i.e. gunzip -- *.gz
– steeldriver
Nov 3 '15 at 13:29
@steeldriver yes I do have a few files starting with -
– Herman Toothrot
Nov 3 '15 at 13:47
@steeldriver yes I do have a few files starting with -
– Herman Toothrot
Nov 3 '15 at 13:47
that caused at least one of the two problems.
– Herman Toothrot
Nov 3 '15 at 14:25
that caused at least one of the two problems.
– Herman Toothrot
Nov 3 '15 at 14:25
add a comment |
3 Answers
3
active
oldest
votes
You can use below command.
Go to the directory where your .gz
file is and run command:
for f in *.gz ; do gunzip -c "$f" > /home/$USER/"${f%.*}" ; done
It will extract all file with original name and store it to current user home directory(/home/username
). You can change it to somewhere else.
EDIT :
gunzip *.gz
This command also will work. But, by default, it replaces original file.
Have you read what I wrote in my question? gunzip *.gz is not working for me. But the for loop works, I am puzzled.
– Herman Toothrot
Nov 3 '15 at 13:24
but it is working for me and others also why is showing ` invalid option -- 'Y' ` . i think either your file format is not ok or you missing some thing in command.
– pl_rock
Nov 3 '15 at 13:26
also see unix.stackexchange.com/questions/56421/…
– pl_rock
Nov 3 '15 at 13:27
add a comment |
Option # 1 : unzip multiple files using single quote (short version)
gunzip '*.gz'
Note that *.gz
word is put in between two single quote, so that shell will not recognize it as a wild card character.
Option # 2 : unzip multiple files using shell for loop (long version)
for g in *.gz; do gunzip $g; done
The Source
EDIT :
I have just tried :
gunzip -dk *.gz
and it worked.
-d
to decompress and k
to keep original files.
have you checkedgunzip ‘*.gz’
this command . i am not able to run this command . it giving error .
– pl_rock
Nov 3 '15 at 13:08
usegunzip '*.gz'
notgunzip ‘*.gz’
(' '
not `‘ ``)
– Bilal
Nov 3 '15 at 13:16
i am just copy pasting your command and it givinggzip: *.gz: No such file or directory
new also not working . have u tried ?
– pl_rock
Nov 3 '15 at 13:19
It does not work gunzip '*.gz' gzip: *.gz: No such file or directory
– Herman Toothrot
Nov 3 '15 at 13:23
Sorry, i didn'ttry it ! i'm on WIndows Right now :(
– Bilal
Nov 3 '15 at 13:26
add a comment |
Linux Users:
Use the following command for extracting minimum amount of .gz files in the current directory and its sub directories
gunzip *.gz
Use the following command for extracting any number of .gz files in the current directory and its sub directories
sudo find . -name "*.gz" | xargs gunzip
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f693409%2fhow-can-i-extract-multiple-gzip-files-in-directory-and-subdirectories%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use below command.
Go to the directory where your .gz
file is and run command:
for f in *.gz ; do gunzip -c "$f" > /home/$USER/"${f%.*}" ; done
It will extract all file with original name and store it to current user home directory(/home/username
). You can change it to somewhere else.
EDIT :
gunzip *.gz
This command also will work. But, by default, it replaces original file.
Have you read what I wrote in my question? gunzip *.gz is not working for me. But the for loop works, I am puzzled.
– Herman Toothrot
Nov 3 '15 at 13:24
but it is working for me and others also why is showing ` invalid option -- 'Y' ` . i think either your file format is not ok or you missing some thing in command.
– pl_rock
Nov 3 '15 at 13:26
also see unix.stackexchange.com/questions/56421/…
– pl_rock
Nov 3 '15 at 13:27
add a comment |
You can use below command.
Go to the directory where your .gz
file is and run command:
for f in *.gz ; do gunzip -c "$f" > /home/$USER/"${f%.*}" ; done
It will extract all file with original name and store it to current user home directory(/home/username
). You can change it to somewhere else.
EDIT :
gunzip *.gz
This command also will work. But, by default, it replaces original file.
Have you read what I wrote in my question? gunzip *.gz is not working for me. But the for loop works, I am puzzled.
– Herman Toothrot
Nov 3 '15 at 13:24
but it is working for me and others also why is showing ` invalid option -- 'Y' ` . i think either your file format is not ok or you missing some thing in command.
– pl_rock
Nov 3 '15 at 13:26
also see unix.stackexchange.com/questions/56421/…
– pl_rock
Nov 3 '15 at 13:27
add a comment |
You can use below command.
Go to the directory where your .gz
file is and run command:
for f in *.gz ; do gunzip -c "$f" > /home/$USER/"${f%.*}" ; done
It will extract all file with original name and store it to current user home directory(/home/username
). You can change it to somewhere else.
EDIT :
gunzip *.gz
This command also will work. But, by default, it replaces original file.
You can use below command.
Go to the directory where your .gz
file is and run command:
for f in *.gz ; do gunzip -c "$f" > /home/$USER/"${f%.*}" ; done
It will extract all file with original name and store it to current user home directory(/home/username
). You can change it to somewhere else.
EDIT :
gunzip *.gz
This command also will work. But, by default, it replaces original file.
edited Oct 22 '17 at 12:30
phenomenon
1586
1586
answered Nov 3 '15 at 12:50
pl_rockpl_rock
7,28542835
7,28542835
Have you read what I wrote in my question? gunzip *.gz is not working for me. But the for loop works, I am puzzled.
– Herman Toothrot
Nov 3 '15 at 13:24
but it is working for me and others also why is showing ` invalid option -- 'Y' ` . i think either your file format is not ok or you missing some thing in command.
– pl_rock
Nov 3 '15 at 13:26
also see unix.stackexchange.com/questions/56421/…
– pl_rock
Nov 3 '15 at 13:27
add a comment |
Have you read what I wrote in my question? gunzip *.gz is not working for me. But the for loop works, I am puzzled.
– Herman Toothrot
Nov 3 '15 at 13:24
but it is working for me and others also why is showing ` invalid option -- 'Y' ` . i think either your file format is not ok or you missing some thing in command.
– pl_rock
Nov 3 '15 at 13:26
also see unix.stackexchange.com/questions/56421/…
– pl_rock
Nov 3 '15 at 13:27
Have you read what I wrote in my question? gunzip *.gz is not working for me. But the for loop works, I am puzzled.
– Herman Toothrot
Nov 3 '15 at 13:24
Have you read what I wrote in my question? gunzip *.gz is not working for me. But the for loop works, I am puzzled.
– Herman Toothrot
Nov 3 '15 at 13:24
but it is working for me and others also why is showing ` invalid option -- 'Y' ` . i think either your file format is not ok or you missing some thing in command.
– pl_rock
Nov 3 '15 at 13:26
but it is working for me and others also why is showing ` invalid option -- 'Y' ` . i think either your file format is not ok or you missing some thing in command.
– pl_rock
Nov 3 '15 at 13:26
also see unix.stackexchange.com/questions/56421/…
– pl_rock
Nov 3 '15 at 13:27
also see unix.stackexchange.com/questions/56421/…
– pl_rock
Nov 3 '15 at 13:27
add a comment |
Option # 1 : unzip multiple files using single quote (short version)
gunzip '*.gz'
Note that *.gz
word is put in between two single quote, so that shell will not recognize it as a wild card character.
Option # 2 : unzip multiple files using shell for loop (long version)
for g in *.gz; do gunzip $g; done
The Source
EDIT :
I have just tried :
gunzip -dk *.gz
and it worked.
-d
to decompress and k
to keep original files.
have you checkedgunzip ‘*.gz’
this command . i am not able to run this command . it giving error .
– pl_rock
Nov 3 '15 at 13:08
usegunzip '*.gz'
notgunzip ‘*.gz’
(' '
not `‘ ``)
– Bilal
Nov 3 '15 at 13:16
i am just copy pasting your command and it givinggzip: *.gz: No such file or directory
new also not working . have u tried ?
– pl_rock
Nov 3 '15 at 13:19
It does not work gunzip '*.gz' gzip: *.gz: No such file or directory
– Herman Toothrot
Nov 3 '15 at 13:23
Sorry, i didn'ttry it ! i'm on WIndows Right now :(
– Bilal
Nov 3 '15 at 13:26
add a comment |
Option # 1 : unzip multiple files using single quote (short version)
gunzip '*.gz'
Note that *.gz
word is put in between two single quote, so that shell will not recognize it as a wild card character.
Option # 2 : unzip multiple files using shell for loop (long version)
for g in *.gz; do gunzip $g; done
The Source
EDIT :
I have just tried :
gunzip -dk *.gz
and it worked.
-d
to decompress and k
to keep original files.
have you checkedgunzip ‘*.gz’
this command . i am not able to run this command . it giving error .
– pl_rock
Nov 3 '15 at 13:08
usegunzip '*.gz'
notgunzip ‘*.gz’
(' '
not `‘ ``)
– Bilal
Nov 3 '15 at 13:16
i am just copy pasting your command and it givinggzip: *.gz: No such file or directory
new also not working . have u tried ?
– pl_rock
Nov 3 '15 at 13:19
It does not work gunzip '*.gz' gzip: *.gz: No such file or directory
– Herman Toothrot
Nov 3 '15 at 13:23
Sorry, i didn'ttry it ! i'm on WIndows Right now :(
– Bilal
Nov 3 '15 at 13:26
add a comment |
Option # 1 : unzip multiple files using single quote (short version)
gunzip '*.gz'
Note that *.gz
word is put in between two single quote, so that shell will not recognize it as a wild card character.
Option # 2 : unzip multiple files using shell for loop (long version)
for g in *.gz; do gunzip $g; done
The Source
EDIT :
I have just tried :
gunzip -dk *.gz
and it worked.
-d
to decompress and k
to keep original files.
Option # 1 : unzip multiple files using single quote (short version)
gunzip '*.gz'
Note that *.gz
word is put in between two single quote, so that shell will not recognize it as a wild card character.
Option # 2 : unzip multiple files using shell for loop (long version)
for g in *.gz; do gunzip $g; done
The Source
EDIT :
I have just tried :
gunzip -dk *.gz
and it worked.
-d
to decompress and k
to keep original files.
edited Nov 3 '15 at 14:35
answered Nov 3 '15 at 12:58
BilalBilal
2,6831430
2,6831430
have you checkedgunzip ‘*.gz’
this command . i am not able to run this command . it giving error .
– pl_rock
Nov 3 '15 at 13:08
usegunzip '*.gz'
notgunzip ‘*.gz’
(' '
not `‘ ``)
– Bilal
Nov 3 '15 at 13:16
i am just copy pasting your command and it givinggzip: *.gz: No such file or directory
new also not working . have u tried ?
– pl_rock
Nov 3 '15 at 13:19
It does not work gunzip '*.gz' gzip: *.gz: No such file or directory
– Herman Toothrot
Nov 3 '15 at 13:23
Sorry, i didn'ttry it ! i'm on WIndows Right now :(
– Bilal
Nov 3 '15 at 13:26
add a comment |
have you checkedgunzip ‘*.gz’
this command . i am not able to run this command . it giving error .
– pl_rock
Nov 3 '15 at 13:08
usegunzip '*.gz'
notgunzip ‘*.gz’
(' '
not `‘ ``)
– Bilal
Nov 3 '15 at 13:16
i am just copy pasting your command and it givinggzip: *.gz: No such file or directory
new also not working . have u tried ?
– pl_rock
Nov 3 '15 at 13:19
It does not work gunzip '*.gz' gzip: *.gz: No such file or directory
– Herman Toothrot
Nov 3 '15 at 13:23
Sorry, i didn'ttry it ! i'm on WIndows Right now :(
– Bilal
Nov 3 '15 at 13:26
have you checked
gunzip ‘*.gz’
this command . i am not able to run this command . it giving error .– pl_rock
Nov 3 '15 at 13:08
have you checked
gunzip ‘*.gz’
this command . i am not able to run this command . it giving error .– pl_rock
Nov 3 '15 at 13:08
use
gunzip '*.gz'
not gunzip ‘*.gz’
(' '
not `‘ ``)– Bilal
Nov 3 '15 at 13:16
use
gunzip '*.gz'
not gunzip ‘*.gz’
(' '
not `‘ ``)– Bilal
Nov 3 '15 at 13:16
i am just copy pasting your command and it giving
gzip: *.gz: No such file or directory
new also not working . have u tried ?– pl_rock
Nov 3 '15 at 13:19
i am just copy pasting your command and it giving
gzip: *.gz: No such file or directory
new also not working . have u tried ?– pl_rock
Nov 3 '15 at 13:19
It does not work gunzip '*.gz' gzip: *.gz: No such file or directory
– Herman Toothrot
Nov 3 '15 at 13:23
It does not work gunzip '*.gz' gzip: *.gz: No such file or directory
– Herman Toothrot
Nov 3 '15 at 13:23
Sorry, i didn'ttry it ! i'm on WIndows Right now :(
– Bilal
Nov 3 '15 at 13:26
Sorry, i didn'ttry it ! i'm on WIndows Right now :(
– Bilal
Nov 3 '15 at 13:26
add a comment |
Linux Users:
Use the following command for extracting minimum amount of .gz files in the current directory and its sub directories
gunzip *.gz
Use the following command for extracting any number of .gz files in the current directory and its sub directories
sudo find . -name "*.gz" | xargs gunzip
New contributor
add a comment |
Linux Users:
Use the following command for extracting minimum amount of .gz files in the current directory and its sub directories
gunzip *.gz
Use the following command for extracting any number of .gz files in the current directory and its sub directories
sudo find . -name "*.gz" | xargs gunzip
New contributor
add a comment |
Linux Users:
Use the following command for extracting minimum amount of .gz files in the current directory and its sub directories
gunzip *.gz
Use the following command for extracting any number of .gz files in the current directory and its sub directories
sudo find . -name "*.gz" | xargs gunzip
New contributor
Linux Users:
Use the following command for extracting minimum amount of .gz files in the current directory and its sub directories
gunzip *.gz
Use the following command for extracting any number of .gz files in the current directory and its sub directories
sudo find . -name "*.gz" | xargs gunzip
New contributor
New contributor
answered 3 mins ago
kmsvigneshkmsvignesh
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f693409%2fhow-can-i-extract-multiple-gzip-files-in-directory-and-subdirectories%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Does the directory contain .gz files whose names start with hyphens, such as
-Y.something.gz
? If so you may need to use the Gnu--
flag to ensure that they are treated as filenames rather than options i.e.gunzip -- *.gz
– steeldriver
Nov 3 '15 at 13:29
@steeldriver yes I do have a few files starting with -
– Herman Toothrot
Nov 3 '15 at 13:47
that caused at least one of the two problems.
– Herman Toothrot
Nov 3 '15 at 14:25