Book Image

Linux Shell Scripting Cookbook

By : Sarath Lakshman
Book Image

Linux Shell Scripting Cookbook

By: Sarath Lakshman

Overview of this book

<p>GNU/Linux is a remarkable operating system that comes with a complete development environment that is stable, reliable, and extremely powerful. The shell being the native interface to communicate with the operating system is capable of controlling the entire operating system. There are numerous commands on Linux shell which are documented but hard to understand. The man pages are helpful but they are very lengthy and it does not give any clues on key areas where commands can be used. Proper usage of shell commands can easily solve many complex tasks with a few lines of code, but most linux users don't have the right know-how to use the Linux shell to its full potential.<br /><br />Linux Shell Scripting Cookbook is a collection of essential command-line recipes along with detailed descriptions tuned with practical applications. It covers most of the commands on Linux with a variety of usecases accompanied by plenty of examples. This book helps you to perform complex data manipulations involving tasks such as text processing, file management, backups and more with the combination of few commands.<br /><br />Linux Shell Scripting Cookbook shows you how to capitalize on all the aspects of Linux using the shell scripting language. This book teaches you how to use commands to perform simple tasks all the way to scripting complex tasks such as managing large amounts of data on a network.</p> <p>It guides you on implementing some of the most common commands in Linux with recipes that handle any of the operations or properties related with files like searching and mining inside a file with grep. It also shows you how utilities such as sed, awk, grep, cut can be combined to solve text processing related problems. The focus is on saving time by automating many activities that we perform interactively through as browser with a few lines of script.</p> <p>This book will take you from a clear problem description to a fully functional program. The recipes contained within the chapter will introduce the reader to specific problems and provide hands-on solutions.</p>
Table of Contents (16 chapters)
Linux Shell Scripting Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Downloading from a web page


Downloading a file or a web page from a given URL is simple. A few command-line download utilities are available to perform this task.

Getting ready

wget is a file download command-line utility. It is very flexible and can be configured with many options.

How to do it...

A web page or a remote file can be downloaded using wget as follows:

$ wget URL

For example:

$ wget http://slynux.org 
--2010-08-01 07:51:20--  http://slynux.org/ 
Resolving slynux.org... 174.37.207.60 
Connecting to slynux.org|174.37.207.60|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 15280 (15K) [text/html] 
Saving to: "index.html" 

100%[======================================>] 15,280      75.3K/s   in 0.2s    

2010-08-01 07:51:21 (75.3 KB/s) - "index.html" saved [15280/15280]

It is also possible to specify multiple download URLs as follows:

$ wget URL1 URL2 URL3 ..

A file can be downloaded using wget using the URL as:

$ wget ftp://example_domain.com/somefile...