LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chmod problem (https://www.linuxquestions.org/questions/linux-newbie-8/chmod-problem-4175485915/)

validator456 11-26-2013 06:59 AM

chmod problem
 
I have to change the file permissions for a large amount of files (17 or so).
I can create a new directory and then move the files to this directory and then change all the files permissions within it.

But I was trying something else:
Code:

ls -m
The files of the directory are seperated by a comma. I then copied the files I wanted to change the permissions.

Then I run nano in the terminal. Search and replace (CTRL-\). I removed the commas by empty space.

Then I tried to copy and paste the result after the command
Code:

sudo chmod 664
. But it only pasted the first line of the files. And I want all 17 files in one go.

I hope I have been clear enough.

druuna 11-26-2013 07:15 AM

Why use the -m option and not the -C option?
Code:

sudo chmod 664 $(ls -C)

ixion2600 11-26-2013 08:57 AM

Or you can use the -R option, for recursive, if you moved all of them in one place:

chmod 664 -R /path/to/directory

man chmod:

...
-R, --recursive
change files and directories recursively (this will modify the permissions for all files and sub-directories in the path)
...
This does the same thing:

find /path/to/directory -type f -exec chmod 644 {} \; (this will modify the permissions for all files and sub-directories in the path)

if you have your files in /home/user/test ... but have another directory there test2 and files inside, it will modify the permissions there as well.

validator456 11-26-2013 10:38 AM

Yes, I do know about the possibility of moving all of the files in one place and then do the -R method.

But I don't want to make a submap. I don't want to move the files. I just wanted to change the file permissions of SOME of the files in a map.

And ls -C doesn't allow you to select the files that you want.

But I guess that I am doing difficult and that I just have to create a map and move the files that I want to change over there.

Thank you for answering my question.

druuna 11-26-2013 10:54 AM

Quote:

Originally Posted by validator456 (Post 5070897)
And ls -C doesn't allow you to select the files that you want.

Why not?
Code:

$ ls -l
-rw-r----- 1 druuna druuna    0 nov 26 17:52 bar
-rw-r----- 1 druuna druuna    0 nov 26 17:52 foo
-rw-r----- 1 druuna druuna    0 nov 26 17:52 foobar
-rw-r----- 1 druuna druuna    0 nov 26 17:52 fubar
-rw-r----- 1 druuna druuna    0 nov 26 17:52 one
-rw-r----- 1 druuna druuna    0 nov 26 17:52 test
$ ls -C f*
foo  foobar  fubar


validator456 11-26-2013 11:51 AM

In one word: brilliant.


All times are GMT -5. The time now is 01:42 AM.