G
G
Ghost_Inq2015-02-27 15:03:56
linux
Ghost_Inq, 2015-02-27 15:03:56

How to automatically create a file with all possible permissions in linux?

How to create empty files with all possible combinations of access rights, and the file name should look like rwx-wx--x.txt
That is, correspond to the rights

Answer the question

In order to leave comments, you need to log in

4 answer(s)
J
jcmvbkbc, 2015-02-27
@jcmvbkbc

bash:

touch {0..7}{0..7}{0..7}.txt
echo -n {0..7}{0..7}{0..7} | xargs -d ' ' -I{} chmod {} {}.txt

Symbolically:
touch u={,r}{,w}{,x},g={,r}{,w}{,x},o={,r}{,w}{,x}.txt
echo -n u={,r}{,w}{,x},g={,r}{,w}{,x},o={,r}{,w}{,x} | xargs -d ' ' -I{} chmod {} {}.txt

L
ldv, 2015-02-27
@ldvldv

#! /bin/bash

let "i=0"
echo $i
while  [ $i -lt 512 ]
do

touch tmp
chmod $(printf %o $i) tmp
mv -- tmp "$(ls -l tmp | cut -d' ' -f1).txt"
let "i=i+1"

done

K
Konstantin, 2015-02-27
@fallen8rwtf

locally?
look towards aliases in bashrc

P
prosto565, 2015-02-27
@prosto565

Something like

COUNTER=0; while [  $COUNTER -lt 777 ]; do touch $COUNTER.txt; chmod $COUNTER $COUNTER.txt; let COUNTER=COUNTER+1; done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question