Joaquin Peralta

My Personal weblog.

Change File Permissions

Many times when you copy a direcotry or files from a cdrom or another device, the files not have appropiate permisions, for this reasons i make a little command ofr change automatically the file permissions.

Edit a new file, and copy and paste this :

———————————————————————————————————-

#/usr/bin/sh
#Version-0.1
echo “You are in :” $PWD
echo “Warning : The permissions are modified recursively.”
echo “Put permissions for the directories (ej:755) :”
read PD
echo “Permissions for Files (ej:644) :”
read PF

echo “Warning2 : The hidden files are modified too.”
echo “Press enter for conitnue – or Control-C to cancel.”
read
echo “Change File permission – please wait.”
find -type f | sed ’s/.*/”&”/’ |sed -e ’s/”.\//chmod ‘$PF’ “/’ | sh
echo “Change Directory permissions – please wait.”
find -type d | sed ’s/.*/”&”/’ |sed -e ’s/”.\//chmod ‘$PD’ “/’|grep chmod | sh
echo “Thanks… problems to jperaltac-at-gmail-dot-com”

———————————————————————————————————-
After this save this file, i have this with the perglob name, and move this script to your personal scripts directory, see the last post. And you have a new command called perglob, and if your run this command in the directory where you want change permissions, the scripts change the permissions automatically, i recommend that you use 755 for directory and 644 for files the first time.

This is all.

JP.

July 10, 2006 Posted by jperalta | GNU/Linux | | No Comments Yet