PIPELINES Create a pipeline of the following commands: find | xargs file --mime-type | sort To list all files in the /et
Posted: Mon Jun 06, 2022 2:22 pm
PIPELINES
Create a pipeline of the following commands:
find | xargs file --mime-type |
sort
To list all files in the /etc file hierarchy, grouped by type of
file (symbolic link, empty, directory, data, C source, etc.). Each
of the above commands will need to be researched to determine the
options required to make them behave as desired. In general:
The finished output will look similar to (note this example is
correct, but incomplete):
/etc/ld.so.cache:
application/octet-stream
/etc/pacman.d/gnupg/trustdb.gpg:
application/octet-stream
/etc/pacman.d/gnupg/pubring.gpg:
application/pgp-keys
/etc/pacman.d/gnupg/pubring.gpg~:
application/pgp-keys
/etc/ssh:
inode/directory
/etc/ssl:
inode/directory
/etc/X11:
inode/directory
/etc/xdg:
inode/directory
/etc/skel:
inode/directory
/etc/udev:
inode/directory
/etc/audit:
inode/directory
/etc/libnl:
inode/directory
/etc/pam.d:
inode/directory
/etc/audisp:
inode/directory
/etc/dbus-1:
inode/directory
/etc/ssl/certs/03179a64.0:
inode/symlink
/etc/ssl/certs/04f60c28.0:
inode/symlink
/etc/ssl/certs/062cdee6.0:
inode/symlink
/etc/ssl/certs/064e0aa9.0:
inode/symlink
/etc/ssl/certs/06dc52d5.0:
inode/symlink
/etc/sudoers:
regular
file, no read permission
/etc/crypttab:
regular
file, no read permission
/etc/gshadow-:
regular
file, no read permission
/etc/libaudit.conf:
regular file, no read
permission
/etc/hosts:
text/plain
/etc/issue:
text/plain
/etc/vimrc:
text/plain
/etc/group-:
text/plain
/etc/nanorc:
text/plain
After the above is working, change your pipeline to produce a
list of unique file types. The pipeline will be:
find | xargs file --mime-type | tr | cut |
sort | uniq
The list of unique file types looks similar to:
application/octet-stream
application/pgp-keys
application/x-java-keystore
application/x-sqlite3
inode/directory
inode/socket
inode/symlink
inode/x-empty
regular file, no read permission
text/plain
text/x-Algol68
text/x-makefile
text/x-perl
text/x-shellscript
Attach a bash script of the two pipelines of commands.
Create a pipeline of the following commands:
find | xargs file --mime-type |
sort
To list all files in the /etc file hierarchy, grouped by type of
file (symbolic link, empty, directory, data, C source, etc.). Each
of the above commands will need to be researched to determine the
options required to make them behave as desired. In general:
The finished output will look similar to (note this example is
correct, but incomplete):
/etc/ld.so.cache:
application/octet-stream
/etc/pacman.d/gnupg/trustdb.gpg:
application/octet-stream
/etc/pacman.d/gnupg/pubring.gpg:
application/pgp-keys
/etc/pacman.d/gnupg/pubring.gpg~:
application/pgp-keys
/etc/ssh:
inode/directory
/etc/ssl:
inode/directory
/etc/X11:
inode/directory
/etc/xdg:
inode/directory
/etc/skel:
inode/directory
/etc/udev:
inode/directory
/etc/audit:
inode/directory
/etc/libnl:
inode/directory
/etc/pam.d:
inode/directory
/etc/audisp:
inode/directory
/etc/dbus-1:
inode/directory
/etc/ssl/certs/03179a64.0:
inode/symlink
/etc/ssl/certs/04f60c28.0:
inode/symlink
/etc/ssl/certs/062cdee6.0:
inode/symlink
/etc/ssl/certs/064e0aa9.0:
inode/symlink
/etc/ssl/certs/06dc52d5.0:
inode/symlink
/etc/sudoers:
regular
file, no read permission
/etc/crypttab:
regular
file, no read permission
/etc/gshadow-:
regular
file, no read permission
/etc/libaudit.conf:
regular file, no read
permission
/etc/hosts:
text/plain
/etc/issue:
text/plain
/etc/vimrc:
text/plain
/etc/group-:
text/plain
/etc/nanorc:
text/plain
After the above is working, change your pipeline to produce a
list of unique file types. The pipeline will be:
find | xargs file --mime-type | tr | cut |
sort | uniq
The list of unique file types looks similar to:
application/octet-stream
application/pgp-keys
application/x-java-keystore
application/x-sqlite3
inode/directory
inode/socket
inode/symlink
inode/x-empty
regular file, no read permission
text/plain
text/x-Algol68
text/x-makefile
text/x-perl
text/x-shellscript
Attach a bash script of the two pipelines of commands.