Mastering Linux Shell Scripting by Andrew Mallett
Author:Andrew Mallett [Mallett, Andrew]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2015-12-23T23:00:00+00:00
We have provided two functions within the script. The first, is_file, simply tests to ensure that the filename we have entered is a regular file. Then we declare the clean_file function with a little added functionality, displaying the line count of the file before and after the operation. We can also see that functions can be nested and we call the is_file function with clean_file.
Without the function definitions we have only three lines of code at the end of the file that we can see in the example code laid out in the previous code block and has been save as $HOME/bin/clean.sh. We first prompt for the filename and then run the clean_file function, which in turn calls the is_file function. The simplicity of the main code is important here. The complexity is in the functions, as each function can be worked on as a standalone unit.
We can now test the script operation, first using a wrong filename, as we can see in the following screenshot:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Disaster & Recovery | Email Administration |
Linux & UNIX Administration | Storage & Retrieval |
Windows Administration |
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7772)
Grails in Action by Glen Smith Peter Ledbrook(7686)
Configuring Windows Server Hybrid Advanced Services Exam Ref AZ-801 by Chris Gill(6498)
Azure Containers Explained by Wesley Haakman & Richard Hooper(6471)
Running Windows Containers on AWS by Marcio Morales(5996)
Kotlin in Action by Dmitry Jemerov(5048)
Microsoft 365 Identity and Services Exam Guide MS-100 by Aaron Guilmette(4870)
Combating Crime on the Dark Web by Nearchos Nearchou(4457)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4412)
Microsoft Cybersecurity Architect Exam Ref SC-100 by Dwayne Natwick(4256)
The Ruby Workshop by Akshat Paul Peter Philips Dániel Szabó and Cheyne Wallace(4131)
The Age of Surveillance Capitalism by Shoshana Zuboff(3943)
Python for Security and Networking - Third Edition by José Manuel Ortega(3686)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3503)
The Ultimate Docker Container Book by Schenker Gabriel N.;(3362)
Mastering Python for Networking and Security by José Manuel Ortega(3341)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3326)
Blockchain Basics by Daniel Drescher(3292)
Learn Wireshark by Lisa Bock(3181)
