Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Linux Command Line and Shell Scripting Techniques

You're reading from   Linux Command Line and Shell Scripting Techniques Master practical aspects of the Linux command line and then use it as a part of the shell scripting process

Arrow left icon
Product type Paperback
Published in Mar 2022
Publisher Packt
ISBN-13 9781800205192
Length 552 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Jasmin Redzepagic Jasmin Redzepagic
Author Profile Icon Jasmin Redzepagic
Jasmin Redzepagic
Vedran Dakic Vedran Dakic
Author Profile Icon Vedran Dakic
Vedran Dakic
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Chapter 1: Basics of Shell and Text Terminal 2. Chapter 2: Using Text Editors FREE CHAPTER 3. Chapter 3: Using Commands and Services for Process Management 4. Chapter 4: Using Shell to Configure and Troubleshoot a Network 5. Chapter 5: Using Commands for File, Directory, and Service Management 6. Chapter 6: Shell-Based Software Management 7. Chapter 7: Network-Based File Synchronization 8. Chapter 8: Using the Command Line to Find, Extract, and Manipulate Text Content 9. Chapter 9: An Introduction to Shell Scripting 10. Chapter 10: Using Loops 11. Chapter 11: Working with Variables 12. Chapter 12: Using Arguments and Functions 13. Chapter 13: Using Arrays 14. Chapter 14: Interacting with Shell Scripts 15. Chapter 15: Troubleshooting Shell Scripts 16. Chapter 16: Shell Script Examples for Server Management, Network Configuration, and Backups 17. Chapter 17: Advanced Shell Script Examples 18. Other Books You May Enjoy

Creating a file and folder inventory

Let's start with something basic – a script that reports in terms of folder and file inventory. As simple as this is, this type of script can use a variety of different tools, including commands, built-in CLI applications, loops – there are a lot of choices to be made. We're going to do this in the simplest way possible – by taking advantage of our knowledge of commands and CLI applications. We're going to create a couple of different versions of this script as it can be used in a variety of different ways – for example, as input into future shell scripts or as plain text reporting tools.

How to do it…

Let's start by creating a script that's just going to tell us the following:

  • The number of folders in the current folder and their sizes, sorted by size in descending order
  • The number of files in the current folder and their size, sorted by size in descending order
...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image