Determine the number of directories inside a tar file without extracting itSearch for a file inside a tar.gz file without extracting it and copy the result to another folderTransform a tar archive's paths without extracting itView a file in a tar archive without extracting itTar - Transform stdin without extractingTar: Extract only files (not sub-directories)Exclude some files when extracting with tarExtract specific directories with all subdirectories from a tar fileuntar file without subdirectories containing ittar doesn't find a file in an archive, depending on the command used to try to extract itIs there an efficient command for listing the header of a particular file in tar.bz2 without uncompressing/extracting?
Would a high gravity rocky planet be guaranteed to have an atmosphere?
How to be diplomatic in refusing to write code that breaches the privacy of our users
Method to test if a number is a perfect power?
Purchasing a ticket for someone else in another country?
How to run a prison with the smallest amount of guards?
Customer Requests (Sometimes) Drive Me Bonkers!
A Rare Riley Riddle
Integer addition + constant, is it a group?
Go Pregnant or Go Home
Why are there no referendums in the US?
Do sorcerers' Subtle Spells require a skill check to be unseen?
How to Reset Passwords on Multiple Websites Easily?
Failed to fetch jessie backports repository
Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?
How to pronounce the slash sign
Escape a backup date in a file name
Valid Badminton Score?
India just shot down a satellite from the ground. At what altitude range is the resulting debris field?
Why escape if the_content isnt?
Was Spock the First Vulcan in Starfleet?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
How do I find the solutions of the following equation?
Tiptoe or tiphoof? Adjusting words to better fit fantasy races
Unreliable Magic - Is it worth it?
Determine the number of directories inside a tar file without extracting it
Search for a file inside a tar.gz file without extracting it and copy the result to another folderTransform a tar archive's paths without extracting itView a file in a tar archive without extracting itTar - Transform stdin without extractingTar: Extract only files (not sub-directories)Exclude some files when extracting with tarExtract specific directories with all subdirectories from a tar fileuntar file without subdirectories containing ittar doesn't find a file in an archive, depending on the command used to try to extract itIs there an efficient command for listing the header of a particular file in tar.bz2 without uncompressing/extracting?
I need to count directories inside an archive file (e.g. tar.bz) without extracting the archive. Note that the archive is too big so that it will be hard to extract then count directories using ls | wc -l
.
directory tar archive wc
add a comment |
I need to count directories inside an archive file (e.g. tar.bz) without extracting the archive. Note that the archive is too big so that it will be hard to extract then count directories using ls | wc -l
.
directory tar archive wc
Top-level directories or including every subdirectory?
– Jeff Schaller♦
yesterday
I want to count top-level directories actually? But if you can give a hint on how to recursively count or specify a certain depth, it would be perfect.
– Tung
yesterday
add a comment |
I need to count directories inside an archive file (e.g. tar.bz) without extracting the archive. Note that the archive is too big so that it will be hard to extract then count directories using ls | wc -l
.
directory tar archive wc
I need to count directories inside an archive file (e.g. tar.bz) without extracting the archive. Note that the archive is too big so that it will be hard to extract then count directories using ls | wc -l
.
directory tar archive wc
directory tar archive wc
edited yesterday
Jeff Schaller♦
44k1161142
44k1161142
asked yesterday
TungTung
1334
1334
Top-level directories or including every subdirectory?
– Jeff Schaller♦
yesterday
I want to count top-level directories actually? But if you can give a hint on how to recursively count or specify a certain depth, it would be perfect.
– Tung
yesterday
add a comment |
Top-level directories or including every subdirectory?
– Jeff Schaller♦
yesterday
I want to count top-level directories actually? But if you can give a hint on how to recursively count or specify a certain depth, it would be perfect.
– Tung
yesterday
Top-level directories or including every subdirectory?
– Jeff Schaller♦
yesterday
Top-level directories or including every subdirectory?
– Jeff Schaller♦
yesterday
I want to count top-level directories actually? But if you can give a hint on how to recursively count or specify a certain depth, it would be perfect.
– Tung
yesterday
I want to count top-level directories actually? But if you can give a hint on how to recursively count or specify a certain depth, it would be perfect.
– Tung
yesterday
add a comment |
1 Answer
1
active
oldest
votes
This should list all the files from the archive, then find the lines ending with /
(folders) and then take the line count of it:
tar -tvf file.tar | grep '/$' | wc -l
edit: if you want to only count the top level dirs:
tar --exclude='./*/*' -tvf file.tar | grep '/$' | wc -l
If you want to go recursively one level deeper:
tar --exclude='./*/*/*' -tvf file.tar | grep '/$' | wc -l
and so on...
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f508711%2fdetermine-the-number-of-directories-inside-a-tar-file-without-extracting-it%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This should list all the files from the archive, then find the lines ending with /
(folders) and then take the line count of it:
tar -tvf file.tar | grep '/$' | wc -l
edit: if you want to only count the top level dirs:
tar --exclude='./*/*' -tvf file.tar | grep '/$' | wc -l
If you want to go recursively one level deeper:
tar --exclude='./*/*/*' -tvf file.tar | grep '/$' | wc -l
and so on...
add a comment |
This should list all the files from the archive, then find the lines ending with /
(folders) and then take the line count of it:
tar -tvf file.tar | grep '/$' | wc -l
edit: if you want to only count the top level dirs:
tar --exclude='./*/*' -tvf file.tar | grep '/$' | wc -l
If you want to go recursively one level deeper:
tar --exclude='./*/*/*' -tvf file.tar | grep '/$' | wc -l
and so on...
add a comment |
This should list all the files from the archive, then find the lines ending with /
(folders) and then take the line count of it:
tar -tvf file.tar | grep '/$' | wc -l
edit: if you want to only count the top level dirs:
tar --exclude='./*/*' -tvf file.tar | grep '/$' | wc -l
If you want to go recursively one level deeper:
tar --exclude='./*/*/*' -tvf file.tar | grep '/$' | wc -l
and so on...
This should list all the files from the archive, then find the lines ending with /
(folders) and then take the line count of it:
tar -tvf file.tar | grep '/$' | wc -l
edit: if you want to only count the top level dirs:
tar --exclude='./*/*' -tvf file.tar | grep '/$' | wc -l
If you want to go recursively one level deeper:
tar --exclude='./*/*/*' -tvf file.tar | grep '/$' | wc -l
and so on...
edited yesterday
answered yesterday
Jussi HietanenJussi Hietanen
725
725
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f508711%2fdetermine-the-number-of-directories-inside-a-tar-file-without-extracting-it%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
Top-level directories or including every subdirectory?
– Jeff Schaller♦
yesterday
I want to count top-level directories actually? But if you can give a hint on how to recursively count or specify a certain depth, it would be perfect.
– Tung
yesterday