Shell Script to Display Name & Size of a File Whose Size is Greater than 1000 Bytes Last Updated : 20 Apr, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report We must have in situations at least once where we need to list files for their particular size maybe in bytes, kilobytes and so on, there comes a need to minimize tedious task to save time and focus on the required things. So we need certain tools or scripts to do this for us, here's where Linux and shell scripting really shines. It's very easy to make portable shell scripts in Linux. We can make use of some command-line utilities and tools to make it very efficient and easy. Here, we need to list out files with sizes greater than 1000 bytes. Tools and utilities like find, stat, etc can be used to locate and filter files and file systems with much control and functionality. We need to surely embed this tools in a shell script along with some basic conditional and loop statements to make it more programmatic and efficient. Approach The approach of this script is quite important because that's the real logic part that goes in the build is quite syntactical and theoretical. So we need to print files with a size limit. For that we need to iterate or loop over the path or directory specified to look for files, We can make use of command called find to traverse through the input path. Now for checking file sizes we need to make use of a command called stat to store the size of files in the required format(in this case bytes). After that a conditional statement (if block) to check whether the file matches the required conditions, in this case, it should exceed 1000. Below is the implementation: #!/bin/bash read -p "Enter path : " -r filep echo " file path - size " for i in $(find "$filep" -depth); do size=$(stat -c%s "$i") if [ $size -gt 1000 ] then echo $i " - " $size fi done Comment More infoAdvertise with us Next Article Shell Script which Works Similar to the Unix Command HEAD TAIL M meetgor Follow Improve Article Tags : Linux-Unix Shell Script Similar Reads Shell Script to Measure Size of a File Understanding the size of a file is fundamental for various reasons. It allows users to monitor disk space usage, identify large or unnecessary files, and make informed decisions about storage management. The ability to measure file size programmatically through a shell script enhances efficiency an 4 min read Shell Script to Delete the Zero Sized File Using If and For There are many files in our system which are of no use for us as temporary files. So we need to clear all those files, but it is very hectic to find each file and delete them. Here we will create a script that will automatically search for the zero-sized file and delete them all. Before starting, we 2 min read Shell Script to Delete Zero Sized Files From a Directory A zero-sized file is a file that contains no data and has a length of 0. It is also called a zero-byte file. Incomplete transfers can be responsible for the zero-sized file. You can create a zero-sized file intentionally by running the following command in the terminal : touch zero_sized_file_name O 3 min read Python - Get list of files in directory sorted by size In this article, we will be looking at the different approaches to get the list of the files in the given directory in the sorted order of size in the Python programming language. The two different approaches to get the list of files in a directory are sorted by size is as follows: Using os.listdir( 3 min read Shell Script which Works Similar to the Unix Command HEAD TAIL Prerequisites: Bash Scripting, Shell Function Library HEAD and TAIL command print a specified number of lines of a file from the beginning and from the end respectively. If we don't specify a number, the commands print the entire file. We will make a bash script display.sh which takes two to three a 5 min read Python - Get list of files in directory with size In this article, we are going to see how to extract the list of files of the directory along with its size. For this, we will use the OS module. OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a 9 min read Like