LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-28-2017, 06:44 AM   #16
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,879
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930

Quote:
Originally Posted by andrew.comly View Post
I really do appreciate your team spirit, and hope to be able to help you sometime in the future. The only problem is that I am just an independent bash programming student, and haven't even learned how a shellscript can call a perl script yet. This doesn't mean that I don't regard perl as an outstanding language to learn, it's just that it might distract me in my current stage of development. This specific question is no emergency.
Quote:
Originally Posted by andrew.comly View Post
Your right when only counting the amount of lines(how many directories).

Unfortunately, when making a "list", the spaces for this purpose, the spaces end up breaking the list up.
Quote:
Originally Posted by andrew.comly View Post
Yes, find . -type d was previously attempted. Also List=$(find . -type d) was previously attempted, and due to some dir/file names containing spaces, the list is broken (application).
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place.

What you're not indicating here is the exact reason why this list was broken.

It is clear to me that I can create an example directory structure where directories contain spaces in the file names and that find command works perfectly.

You have been unclear about the exact requirements for this list.

I am not asking to see a link to some other question.

I also do not feel it will be helpful to repeat something like your first post where you show code and command attempts only.

What I am asking for is input/output examples and more exact requirements for this desired list.

If you feel that you have covered that topic sufficiently in your other thread in Programming, then I will close this thread to avoid frustrating fellow members and let you continue with that question to resolve your problem.
 
1 members found this post helpful.
Old 06-28-2017, 07:15 AM   #17
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
I did some testing on my computer, at it didn't appear that space mattered, it was like the {} substitution was automatically escaped to ignore the spaces, the entire directory, including the spaces, were passed and processed as one directory or file name.
 
Old 06-28-2017, 08:03 AM   #18
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,790

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
you can use real arrays:
Code:
IFS=$'\n' DIRList=( $(find ee/* -type d) )
for dd in "${DIRList[@]}"
do
    echo $dd
done
 
1 members found this post helpful.
Old 06-28-2017, 06:24 PM   #19
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Thumbs up [solved]

Quote:
Originally Posted by rknichols View Post
It's a lot easier just to let the find command do the work an not have to worry about how the shell will parse the resulting list.
Code:
find AC -type d -exec chmod 700 {} \;
find AC -type f -exec chmod 600 {} +
The first command tells find to execute the chmod command immediately on each directory it discovers since it can't descend into a directory until the appropriate permission has been set. The second command, ending with "+" instead of "\;" allows find to pass as many file names as it can to each invocation of chmod.
Quote:
Originally Posted by NevemTeve View Post
If you mean you want to perform chmod on more than one files/directories, then it is an XY-problem
use find(1): http://www.linuxquestions.org/questi...0/#post5707388
Thanks!!! These two solutions worked great!
 
Old 06-30-2017, 04:25 AM   #20
andrew.comly
Member
 
Registered: Dec 2012
Distribution: Trisquel-Mini 7.0, Lubuntu 14.04, Debian lxde 8.0
Posts: 311

Original Poster
Blog Entries: 2

Rep: Reputation: 16
Question

Quote:
Originally Posted by rtmistler View Post
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place.

What you're not indicating here is the exact reason why this list was broken.

It is clear to me that I can create an example directory structure where directories contain spaces in the file names and that find command works perfectly.

You have been unclear about the exact requirements for this list.

I am not asking to see a link to some other question.

I also do not feel it will be helpful to repeat something like your first post where you show code and command attempts only.

What I am asking for is input/output examples and more exact requirements for this desired list.

If you feel that you have covered that topic sufficiently in your other thread in Programming, then I will close this thread to avoid frustrating fellow members and let you continue with that question to resolve your problem.
This is actually a bit different from the specific application thread.

However, concerning closed threads, I have another thread I merely put up by accident.

The specific story is as follows: I had originally put up the a first thread. Then a minute later I went to edit it, but it wasn't on "my threads". So I thought it got erased or something. Naturally I then copied the tread again from my text file (on my HDD) into your forum again. Then I saved it, logged out and then came back the next day to discover that the first attempt to post hadn't been erased, but it had come back from ghostland and had caused the corrected second attempt post to be marked as a duplicate. Being that there was some valuable replies to the non-corrected first response, is there any way we can erase the corrected second attempt to post and just keep the first? Is that why I have a disabled reputation? Do I have a disabled reputation because my linux ability is a beginner?

It is too bad there is no technical support email that we can email and tell you about things like this.

Last edited by andrew.comly; 07-01-2017 at 01:25 AM. Reason: grammar
 
Old 06-30-2017, 06:32 AM   #21
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,879
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
You can use either the Report button to contact the moderator of the forum where the thread is to ask to move, close, or merge threads. You can also use the Contract Us link to send a message to Jeremy.

Reputation is a setting you can change in your profile to enable or disable.
 
2 members found this post helpful.
Old 07-11-2017, 10:09 PM   #22
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
It seems to me you can use printf maybe?
This appears to be a xy problem, but based on the title..

Code:
find -type d -print0 -exec printf '{}\n' \;
This should enforce a one line per entry regardless of contents (unless of course it contains null characters)
 
  


Reply

Tags
directories, find, list, spaces


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
[SOLVED] I want to extract names with spaces from a list of names! linustalman Linux - General 5 12-02-2011 09:42 AM
[SOLVED] Make list of directories which contain files other than subdirs zainka Programming 9 10-21-2009 04:20 AM
referencing directories with spaces in the names... bbneo Programming 7 06-23-2009 12:15 PM
Is there a way to make certain directories list on top of others with Konqueror? Cinematography Linux - Desktop 2 10-22-2007 10:22 AM
changing subject title names doesn't work on forums A6Quattro LQ Suggestions & Feedback 2 10-17-2005 12:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 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