|
CS469/569 - Linux and Unix Administration and Networking
Spring 2022
|
Displaying ./code/h5/c.sh
#!/bin/bash
# (2 points)
# Given a path on the command line, use stat to print the permissions, user and
# group for each path as you use dirname to walk back up the directory tree to
# root (/).
# Example output:
# > ./c.sh .
# drwxr-xr-x sbaker users /net/sbaker/469/h/hw5
# drwx------ sbaker users /net/sbaker/469/h
# drwx------ sbaker users /net/sbaker/469
# drwx--x--x sbaker users /net/sbaker
# drwxr-xr-x root root /net
# drwxr-xr-x root root /
# Get the path from the first command line argument, if it is not provided, use
# the current working directory (.):
# Use realpath to get the real path:
# If the path isn't to a directory, use dirname to get the directory name:
# While the path is not equal to /, loop:
# Print the permissions, username, groupname, size and path using the stat
# command.
# Use dirname to go up one directory:
|