Question

 

Write a Linux shell script for automatic grouping of files given in a directory. All files will be grouped on the basis of their size and will be saved into the newly created folders based on file size groups given below: Files will be grouped into 0 to 5 kB, 5 kB to 5 MB, 5 MB to 1 GB and greater than 1 GB.

28 May 2025
Answer :
Word Count : 420
A Linux shell script for automatic grouping of files based on size in a directory is a practical implementation of file management and automation under operating system concepts. This script utilizes system calls, file system navigation, and conditional statements—core components of the Unix/Linux environment. It applies networking management principles as well, especially in cases where directories are network-mounted or shared. The script scans all files in the current working directory, checks their sizes using the `stat` command, and moves them into designated directories based on pre-defined size categories: 0–5 KB, 5 KB–5 MB, 5 MB–1 GB, and >1 GB. This task helps manage storage efficiently, which is a key objective in operating system resource management. Here is the script: ```bash #!/bin/bash # Directories to store grouped files mkdir -p group_0_to_5KB mkdir -p group_5KB_to_5MB mkdir
_______ ___ ________ ________ _______ ____ __________ ______ _________ __________ __________ ________.
______ ___ _________ ________ ______ _______ ________ _____ __________ _______.
__________ ______ _______ ___ ______ _________ ____ ____ _____ ________ _______ ______.
_____ ________ _____ _________ ______ ______.
_________ _________ _____ ___ ________ _____ __________ ____ __________.
_______ ______ _________ _______ ________.
________ __________ _____ ____ _________.
______ ______ ________ _____ ________ ________ _________ _______ _______.
______ _______ ___ ______ ______.
_________ _____ ________ _____ _________ _____ ___ ___ _______.
___ _____ ___ _______ ______ ___ _____ ______ ___ ____ ______ ________.
__________ __________ ____ _____ _________ ______ _________ ________ _________.
_____ ___ _____ __________ ______ __________ ____ _______ _______ _____.
________ _______ _________ _______ ___.
____ ______ ___ ___ __________.
____ _______ _________ ___ __________.
______ __________ _____ ______ ______ ___.
___ _____ ______ __________ ____ ___ ____ _____ _____.
______ ________ _____ _____ _____ _____ ____ _____ ___.
__________ ______ _____ _________ __________.
__________ _________ ____ ________ _____ __________.
_________ ___ ______ ___ _____.
________ ______ ________ ________ _____ __________ ______ _____ __________ ________.
____ _______ ________ ___ ______.
_________ _____ ______ ______ _____ _____ __________ _______ ________ ___ _______ ____.
_________ ____ _____ ______ ___.
_______ ______ ________ ____ ____ ______ ___ ___ ________ ____.
___ _____ __________ ______ ______ ______ _______.
_____ _______ ___ _____ ______ ________ _______.
_________ __________ ______ _______ _________ ___ ___.
____ ___ ____ _______ ____ ____ _____.
_________ __________ __________ _____ __________ ____ ___ __________ __________ ____ ____.
__________ _________ ________ ____ _____.
_________ ______ ____ __________ __________ ______ _____ _____.
___ _________ ________ ______ ____ _______ ________.
_____ ________ ________ ___ _________ ___ _____ __________ ____ _______.
____ __________ ________ _______ ____ _____ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 22 2024 2025 -  Write a Linux shell script for automatic grouping of files g | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→