LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-29-2011, 12:05 PM   #1
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Rep: Reputation: 12
Find - Excluding multiple Directories w/o showing files within


Object: Create backup file of chosen directory with 'tar'.

I am trying to write a bash script using 'find' to produce an input file to 'tar'.

The line that creates the input file is below.

find . -type d \( -name JAVASCRIPT -o -name 'jqueryinaction*' \) -prune -o -print | sort > /home/rick/Desktop/tar-include-file

This does exclude the directories I don't want in the current directory and creates the file but it includes all the individual file names also.

I've also tried to use -path in the above with the same results.

The line below creates the correct format but, of course, includes the directories that I don't want.

find . -type d | sort > /home/rick/Desktop/b1-include-file

Thanks in advance for any help you can give me.

R
 
Old 10-29-2011, 12:29 PM   #2
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
You're passing no selection criteria to -print: everything that isn't pruned gets printed.

You want `-type d` before the -print.
 
1 members found this post helpful.
Old 10-29-2011, 05:11 PM   #3
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Original Poster
Rep: Reputation: 12
SOLVED: Thanks jthill that fixed it!
 
  


Reply

Tags
bash, find



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
Find and excluding all hidden directories metallica1973 Linux - General 7 10-28-2011 04:47 PM
[SOLVED] Excluding directories with find metallica1973 Linux - General 4 06-13-2011 05:29 AM
Excluding multiple directories flamingo_l Linux - Newbie 11 08-03-2010 03:45 AM
Find excluding multiple directories with a wildcard pteigeler Linux - Software 1 09-02-2005 10:57 AM
find and copy files into multiple directories avargas22 Linux - Newbie 2 04-01-2004 11:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:36 PM.

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