Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-29-2011, 01:05 PM   #1
Registered: Jun 2005
Location: Sagle, ID
Distribution: Ubuntu 14.04
Posts: 108

Rep: Reputation: 0
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.

Old 10-29-2011, 01:29 PM   #2
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, 06:11 PM   #3
Registered: Jun 2005
Location: Sagle, ID
Distribution: Ubuntu 14.04
Posts: 108

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


bash, find

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

All times are GMT -5. The time now is 03:04 AM.

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