The guys from the promised database lands had their systems acting funny. After investigation, they found out that, their files was having the wrong group ownership.
There’s a total of 70,000 files involved. Promised lands or not, manually changing 70,000 files (and folders) is not a good prospect. Well, I could go through the individual sub-folders but I would need to work from the last in-depth sub-folders and work my way out. Even that does not guarantee accuracy, since there might be sub-folders with multiple owners which I’m not suppose to touch. When that happen, then I have to go through it manually looking at each files and folders individually – not good.
There has to be a short-cut.
I know I can locate all the files that needs to be changed it’s ownership by using the following commands -
find ./ -user someuser -group wronggroup -print
It’ll list all the relevant files and sub-folders. At first, maybe I’ll output it into a file, all the results. Manipulate the file into an executable. Append each lines with a “chgrp correctgroup” and have something like – “chgrp correctgroup ./to/the/path/of/the/file”.
I am smart, hey!
Let’s prove that I can be smarter
Vanity and pride are different things, though the words are often used synonymously. A person may be proud without being vain. Pride relates more to our opinion of ourselves; vanity, to what we would have others think of us.
No, I’m just trying to figure out the best way of doing things.
“xargs -t <commands>”
xargs is a command of Unix and most Unix-like operating systems. It is useful when one wants to pass a large number of arguments to a command. Arbitrarily long lists of parameters can't be passed to a command, so xargs will break the list of arguments into sublists small enough to be acceptable.
xargs - build and execute command lines from standard input
The “-t” is for the verbose option. It’ll spew out the output of the commands being executed.
Basically, every time the output of the earlier “find”, it’ll append the extra commands specified and have it executed. Voila, no need to make a separate executable. My solution is thus -
find ./ -user someuser -group wronggroup -print | xargs -t chgrp correctgroup
Happy 4th Anniversary to myself
Merry Christmas everyone!