Print file size with file name using 'find' command in Unix

├Źndice
  1. Introduction
  2. Printing file size with file name using 'find' command
    1. Step 1: Open your terminal
    2. Step 2: Navigate to the directory where you want to search for files
    3. Step 3: Use the 'find' command to search for files
  3. Conclusion

Introduction

If you are working with Unix, you might have come across situations where you need to find files and their sizes. One way to achieve this is by using the 'find' command. In this article, we will discuss how to print file size with file name using 'find' command in Unix.

Printing file size with file name using 'find' command

To print the file size with the file name using the 'find' command, follow the steps below:

Step 1: Open your terminal

First, open your terminal. You can do this by pressing 'Ctrl + Alt + T' on your keyboard or by searching for 'Terminal' in your system's search bar.

Step 2: Navigate to the directory where you want to search for files

Navigate to the directory where you want to search for files using the 'cd' command. For example, if you want to search for files in the 'Documents' directory, type the following command:

cd Documents

Step 3: Use the 'find' command to search for files

Use the 'find' command to search for files and print their size with file name. The command for this is:

find . -type f -printf "%s %pn"

Let's break down this command:

- The 'find' command is used to search for files.
- The '.' represents the current directory.
- The '-type f' option tells 'find' to search only for files.
- The '-printf' option is used to print the size of the file (%s) and the file name (%p).

Conclusion

In conclusion, we have discussed how to print file size with file name using 'find' command in Unix. By using the 'find' command with the appropriate options, we can easily search for files and print their size with file name.

Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *

Go up

Below we inform you of the use we make of the data we collect while browsing our pages. You can change your preferences at any time by accessing the link to the Privacy Area that you will find at the bottom of our main page. More Information