LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-27-2020, 04:32 AM   #1
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Rep: Reputation: Disabled
Question cpio - How to list files in archive without recursing into directories?


Hello! As the title suggests, I'm currently wondering how to accomplish something like this. Let's say I cloned Grub git repo and want to pack it up into a cpio archive. It has a lot of files, and I'd like to see just the archive's folder structure.

Now, with tar I can do something like this:

Code:
tar --exclude='*/*' -tvf grub.tar
Adding more of '*/' to the exclude switch allows me to control the depth of recursion.

Is there an equivalent for the cpio tool? Thank you in advance!
 
Old 04-27-2020, 05:20 AM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
It's more or less the same:
Code:
rpm2cpio qpdf-9.1.0-1.el8.x86_64.rpm | cpio -tv '*qpdf*'

Last edited by shruggy; 04-27-2020 at 05:27 AM.
 
Old 04-27-2020, 06:06 AM   #3
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Lightbulb

Thank you for your suggestion! Unfortunately, it still seems to recurse into every directory inside the archive. I found bsdcpio though, and it seems to have the option I want.

Code:
bsdcpio -f '*/*' -tv < grub.cpio
This stuff right there seems to do the trick, so I guess it's kind-of solved, hah
 
Old 04-27-2020, 06:14 AM   #4
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
GNU cpio has this option, too (-f aka --nonmatching).
 
1 members found this post helpful.
Old 04-27-2020, 06:23 AM   #5
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Talking

Ooh, neat! Thank you again, it works like a charm!

Code:
cpio -tv -f '*/*' < grub.cpio
Alrighty, looks like it's fully solved now!
 
  


Reply

Tags
cpio, list, recursion



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Is there a way to prepend a CPIO archive file to a Gzip archive file? Roberto Alvarez Slackware 16 07-02-2017 06:14 PM
cpio -idcmv command hanged while extracting .cpio command ravindra.atre Linux - General 2 08-22-2011 04:10 AM
cpio archive does not restore directories. pobman AIX 1 11-24-2008 08:31 PM
How to use cpio to extract a cpio archive? linx win Debian 4 06-17-2005 01:53 PM
How Can I get the Total Size of a Dir w/o Recursing Into it? linuxSysProg Programming 3 08-08-2003 08:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration