Shell Script to Display Name & Size of a File Whose Size is Greater than 1000 Bytes Last Updated : 20 Apr, 2021 Comments Improve Suggest changes 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 to Display Name & Size of a File Whose Size is Greater than 1000 Bytes 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 Shell Script to Count Lines and Words in a File Linux provides users a great cool feature of the command-line tool along with a graphical user interface where they can perform tasks via ruining command. All of this command returns a status according to their execution. Its execution value can be used for showing errors or take some other action i 6 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 C# Program to Estimate the Size of File Using LINQ LINQ is known as Language Integrated Query and it is introduced in .NET 3.5. It gives the ability to .NET languages to generate queries to retrieve data from the data source. It removes the mismatch between programming languages and databases and the syntax used to create a query is the same no matt 2 min read How to get the number of lines in a file using PHP? Given a file reference, find the number of lines in this file using PHP. There are a total of 3 approaches to solve this. test.txt: This file is used for testing all the following PHP codes Geeks For Geeks Approach 1: Load the whole file into memory and then use the count() function to return the nu 2 min read How to access actual name of uploaded file in PHP ? In PHP, we can access the actual name of the file which we are uploading by keyword $_FILES["file"]["name"]. The $_FILES is the by default keyword in PHP to access the details of files that we uploaded.The file refers to the name which is defined in the "index.html" form in the input of the file.The 2 min read Like