I have to translate the permissions of a file this way:
r ► c w ► s x ► e
Then, I must extract the group of characters which are related to owner group. Last step is to print that group of characters without "-" (only letters).
I managed to write a command till now:
student@vm-uso ~team2 $ ls -l partition
-rw-r--r-- 1 student student 10485760 nov 24 21:04 partition
student@vm-uso ~team2 $ ls -l partition | cut -d ' ' -f 1| tr rwx cse | cut -c5-7
c--
student@vm-uso ~team2 $
Forwards, I have to add another '|' in order to print only the letter (without the characters '-').
-
s, then append to the end of your command ...| sed 's/-//g'
.sed
is a tool used to edit inline a stream of text,s/foo/bar/g
means to replace all instances offoo
withbar
(in this case, nothing), and the finalg
means to do so globally.| tr -d -
, which is a little bit liketr - "\0"
except it doesn't insert nul bytes, it just deletes the dashes.