All pastes #913252 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-02-21 22:25 UTC
rendered paste body
#!/bin/bash

declare FileSize
declare GroupName
declare UserName
declare FileName=$1
declare User_Per
declare Group_Per
declare Other_Per
declare File_Per
declare File_Dir
declare Mod_Date
declare User_Sel

File_Per=($(ls -l $FileName | sed 's/^.//p'))
File_Per=($(echo $File_Per | cut -c 1-3):$(echo $File_Per | cut -c 4-6):$(echo $File_Per | cut -c 7-9))
File_Per=($(echo $File_Per | sed 's/r/Read/g'))
File_Per=($(echo $File_Per | sed 's/w/~Write/g'))
File_Per=($(echo $File_Per | sed 's/x/~Execute/g'))
File_Per=($(echo $File_Per | sed 's/-//g'))

Mod_Date=$(ls -l --time-style="+%B %d, %Y at %H:%M" $FileName | cut -d " " -f 6-10)
UserName=($(ls -l $FileName | cut -d " " -f 3))
GroupName=($(ls -l $FileName | cut -d " " -f 4))
FileSize=($(ls -l $FileName | cut -d " " -f 5))
User_Per=($(ls -l $FileName | cut -c 2-4))
Group_Per=($(ls -l $FileName | cut -c 5-7))
Other_Per=($(ls -l $FileName | cut -c 8-10))

echo "File: $FileName"
echo "User: $UserName"
echo "Group: $GroupName"
echo "Size: $FileSize bytes"
echo -n "Permissions: User: "
echo $(echo $File_Per | sed 's/~/ and /g' | cut -d ":" -f 1)
echo -n "            Group: "
echo $(echo $File_Per | sed 's/~/ and /g' | cut -d ":" -f 2)
echo -n "            Other: "
echo $(echo $File_Per | sed 's/~/ and /g' | cut -d ":" -f 3)
echo -n "Modification Date: "
echo $Mod_Date
echo ""

read -p "Would you like to change the permissions on this file (Y/N): " User_Sel
if [[ $User_Sel == "Y" || $User_Sel == "y" ]]
then
        echo "Valid Permission are: RWX or an octal value, a dash (-) will"
        echo "                      leave the permission unchange"
        echo ""
        read -p "New User Permissions (Currently $User_Per): " User_Per
        read -p "New Group Permissions (Currently $Group_Per): " Group_Per
        read -p "New Other Permissions (Currently $Other_Per): " Other_Per
fi