alvas
alvas

Reputation: 122012

How to list all directories/files that you have copy access permission to - Unix

Normally, the ls -la command shows the files and the copy access rights, owners and access group. **

Upvotes: 0

Views: 306

Answers (2)

Hussain Shabbir
Hussain Shabbir

Reputation: 14995

One more answer which will copy only those files whose having copy access permission. For this first navigate to the directory whose file wanted to copy. Also inside this mention your destination path first where you wanted to copy. Try the below:-

destination_Path="/Users/Home/Desktop/test"
b=~/Desktop/copyPermission.txt
if [ ! -f $b ]
then 
touch $b 
fi
a=`ls -l`
e="-----w--w-"
echo "\n$a" | sed '1d' > $b
g=`pwd`
while read line
do 
d=`echo "$line" | awk '{print $1}'`
if [ $e != $d ]
then
r=`echo "$line" | awk '{print $9}'`
echo "Can have copy permission $g/$r" 
{
cp $g/$r "$destination_Path" && echo "copied successfully"
} || {
echo "cannot copy due to some error"
}
#else
#r=`echo "$line" | awk '{print $9}'`
#echo "Cannot have copy permission $r"
fi
done <"$b"

Upvotes: 0

Hussain Shabbir
Hussain Shabbir

Reputation: 14995

Try this:

a=`find $Your_Source_Path -iname "yourFolder_whose_Files_tohide" -prune -o -type f -print`
for i in $a
do
   cp $Your_source $Your_Dest_Path
done

Upvotes: 1

Related Questions