Horje
Create a bash script that asks users to change permission Code Example
Create a bash script that asks users to change permission
#!/bin/bash
until ["$input"= 'no']
do
    echo "Enter the name of file to change permissions"
    read filename
    chmod 777 $filename
    echo "$filename permissions has been changed"
    echo "Would you like to change the permissions of another file?(yes or no)"
    read input
done
    echo "You typed: $input"
Create a bash script that asks users to change permission
#!/bin/bash

# Did user supply an argument (path to folder?)
if [ "${1}" == "" ] ; then
  echo "Directory path required as argument" && exit 1
fi

# Was the arg a valid directory?
if [ ! -d "${1}" ] ; then
  echo "Directory argument was invalid" && exit 1
fi

# Re assign variable
dir="${1}"

# Get a list of files in directory
files=$(ls ${dir})

# Loop over files and ask questions
while file in "${files}" ; do

  # Prompt user for permissions to be set on user/group/owner
  read -p "Set permission for (u)ser/(g)roup/(o)wner? [u|g|o]" who

  # Prompt user for read/write/execute permission to be set
  read -p "Add read/write/execute to ${file}? [r|w|x]" ans

  # Set the specified permission for the specified account type
  chmod ${who}=${ans} ${file}

done




Shell

Related
cut command in unix set diameter Code Example cut command in unix set diameter Code Example
ubuntu command line change line in file Code Example ubuntu command line change line in file Code Example
dolphin service menus Code Example dolphin service menus Code Example
running eslint Code Example running eslint Code Example
How do i search for available packages from the command-line Code Example How do i search for available packages from the command-line Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9