Linux Shell Scripting Cookbook(Linux Shell脚本攻略_英文版.pdf)

2019-03-11 13:33|来源: 网路

中文名:Linux Shell脚本攻略.pdf


Book Description

Solve real-world shell scripting problems with over 110 simple but incredibly effective recipes

  •    Master the art of crafting one-liner command sequence to perform tasks such as text processing, digging data from files, and lot more

  •    Practical problem solving techniques adherent to the latest Linux platform

  •    Packed with easy-to-follow examples to exercise all the features of the Linux shell scripting language

  •    Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible


In Detail

   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.

   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.

   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.

   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.

   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.

   This practical book will help you gain control over all the aspects of Linux using the powerful shell scripting language

What you will learn from this book

  •        Explore a variety of regular usage tasks and how it can be made faster using shell command

  •        Couple frequently used commands like grep, find, sed, awk

  •        Write shell scripts that can dig data from web and process it with few lines of code

  •        Perform and automate tasks such as automating backups and restore with archiving tools

  •        Understand file systems, file types and manipulations

  •        Create and maintain file/folder archives, compression formats and encrypting techniques with shell

  •        Set up Ethernet and Wireless LAN with the shell script

  •        Monitor different activities on the network using logging techniques


Approach

   This book is written in cookbook style and it offers learning through recipes with examples and illustrations. Each recipe contains step-by-step instructions about everything necessary to execute a particular task. The book is designed so that you can read it from start to end for beginner's or just open up any chapter and start following the recipes as a reference for advanced users.

Who this book is written for

   If you are a beginner or an intermediate user who wants to master the skill of quickly writing scripts to perform various tasks without reading the entire man pages, this book is for you. You can start writing scripts and one-liners by simply looking at the similar recipe and its descriptions without any working knowledge of shell scripting or Linux. Intermediate/advanced users as well as system adminstrators/ developers and programmers can use this book as a reference when they face problems while coding.

相关问答

更多
  • 一般以 #!/bin/sh 开头(不是必须要写,但一定要单独一行),指定执行这个脚本的shell程序(也可以用#!/bin/zsh或其他),然后就是堆命令了。Linux的shell脚本支持很多功能,加上Linux高度模块化的命令,完全可以用shell脚本写出复杂的程序。 以上只是简单介绍如何开始写shell脚本,如果要写复杂的脚本,还需要深入学习相关知识(如if——fi、case——esac等结构)。 当然,还需要给脚本加上可执行权限(chmod +x ./file.sh),否则可以用 sh ./file. ...
  • linux的shell script 是有命令加一些条件组合起来的 可以多关注《Linux就该这么学》这本书,我都是从这里面学到的
  • linux 里有很多文档可以帮助学习! 比如 GNU bash, version 3.2.33(1)-release (i386-redhat-linux-gnu) These shell commands are defined internally. Type `help' to see this list. Type `help name' to find out more about the function `name'. Use `info bash' to find out more abou ...
  • 为了编写没有编号的代码,你可以使用ls命令列出当前目录中的文件或使用ls [folder_name]列出文件夹中的文件,为了将结果分配给文件使用$ operator 编辑: 因为ls有一些陷阱,因为@randomir提到使用迭代更好如下: for f in ./* do //do something with $f done In order to write your code without numeration, you can use ls command which lists the f ...
  • Shell脚本具有更简单的I / O重定向符号。 从shell中的现有程序创建管道更为简单。 Shell脚本重用整个程序。 Shell是普遍可用的(在任何类似Unix) - Python不一定被安装。 “真的,你可以在Python中做任何事情,你可以在shell中执行; 这也是真的,在Python中容易的东西在shell中很难(就像在shell中容易的东西,但在Python中很难)。 从长远看,两者都是最好的。 Shell scripting has simpler notations for I/O re ...
  • Shell脚本非常适合简洁的文件系统操作,并且可以通过管道将过滤器和命令行工具中现有功能的组合脚本化。 当您的需求更大时 - 无论是功能性,稳健性,性能,效率等 - 您都可以转向更全面的语言。 他们倾向于提供一些组合: 类型安全 更先进的容器 更好地控制可变生命周期和内存使用情况 穿线 高级IPC,如共享内存和TCP / IP 完整的二进制I / O功能,内存映射文件访问等 访问OS API和无数强大的库 随着项目规模的增加,更好的可读性和可维护性 支持更高级的编程范例:面向对象,函数式编程,生成式编程等。 ...
  • 尝试这个: #!/bin/sh HOST="yourhost" USER="user" PASSWD="pass" FILE="file.txt" ftp -n $HOST <
  • 这是我所知道的如何做到这一点: #!/bin/sh ls $2/*.$1|wc -l 但是,我建议您关注可靠性(检查有效输入)和可维护性(为清晰起见而写)而不是最大的简洁性。 考虑如果没有提供参数会发生什么,例如; 您可能希望显示帮助消息而不是错误消息。 如果参数中包含空格,则此脚本也会失败。 This is as short as I know how to make it: #!/bin/sh ls $2/*.$1|wc -l However, I recommend you focus on re ...
  • 将第一行读入变量 read -r FIRSTLINE < filename 将字符串拆分为单词 WORDS=( $FIRSTLINE ) 循环显示单词并将其输出到文件 for WORD in ${WORDS[@]} do echo $WORD >> outputfilename done 在您的情况下,您希望删除前两列值。 您可以在for语句中使用${WORDS[@]:2来对数组进行切片。 或者,您可以在将它们回显到文件之前测试for循环内的值。 Read the first line into ...
  • 默认情况下,您已经可以访问Dir和File ,这些都是非常有用的。 Dir['*.rb'] #basic globs Dir['**/*.rb'] #** == any depth of directory, including current dir. #=> array of relative names File.expand_path('~/file.txt') #=> "/User/mat/file.txt" File.dirname('dir/file.txt') #=> 'dir' File ...