5 important things to follow to become good in shell scripting

简介: http://unix-school.blogspot.in/2011/07/5-important-things-to-follow-to-become.

http://unix-school.blogspot.in/2011/07/5-important-things-to-follow-to-become.html

Everybody wants solutions to their problems, and more importantly,  we are now expected to get it faster. One can give faster solutions in Unix when one has a good grip on the command line options, and more importantly scripting languages. There are quite a few of them present: Basic Shell scripting, perl scripting, python, ruby, etc. Though our title reads to become good in shell scripting, we in general are going to discuss how to become good in automating things? Or the kind of outlook one needs to have to go in that direction?

    How can one become good in automation? Is it just books one has to read and master or something more? Let us see in this article 5 different traits if one has can turn things around:


1 . Be lazy: The most important trait of all is, to be lazy, to be absolutely lazy. Please don't read between the lines. Being lazy means to show laziness to do the same things repetitively.  The more lazy you are, the more you start disliking tasks of such nature which demand you to grind the same stuff day-in and day-out.  Gradually, you start thinking towards a solution which will get the job done easily, which will achieve the same result with lesser effort which in turn will lead you to automation.  Keep in mind, the world tomorrow is for those who do things better and more importantly, faster.

2. Learn scripting languages: One can give many tips to follow to evince interest in automation, however at the end of the day, it is the individual's choice to show interest in what he or she is doing. We need to be very interested in making things simpler, which makes our life comfortable. Once you start showing interest, you will start doing all the right things such as learning different automation stuffs in UNIX like basic shell scripting, sed, awk, perl, python, ruby,etc. Once you have learnt a scripting language, look out for some potential things or tasks in your project which can be automated. Once you automate something, you will understand the real joy and power behind automation.

3. Pay attention to the smallest of things: An employee's mantra should always be: Make life simple for others.When you are in an organization, you might be in an environment where you will find quite a few things which can be automated. In this case, you have lot of scope for automation. However, it is also possible where you find everything has been automated already in your project, nothing else left or no scope for any more automation. I personally do not accept the fact that there is no scope for automation in any project. The thing you should keep in mind is: Be aware and pay fullest attention to the smallest of things. There are many many things which without realizing we keep doing again and again. Even though it is small, if automated will lead to a considerable time saving. The point I am trying to make is: You need not sit and think what can I automate in my work place. Just pay attention to your day to day activities, you will get hundreds of places where you can automate.

4. Participate in forums: Say, you learnt some scripting language, say shell scripting or perl scripting. If you are working in an environment where you get work on scripting on a regular basis, no issues. However, this may not be the case everywhere or for everybody. Sometimes, you may get a scripting task once in a blue moon, and by the time the next task comes, we have forgotten what we learnt. Due to this, we are in need wherein we need to be continuously in touch with what we have learnt. And the best way to do this is by participating in forums. Everyday, one should spend atleast half-an-hour in a forum. For Unix people, I will always prefer unix.com .

   Participating in forums is not just to remain in touch.  Keep in mind, for every problem, there is more than one way of solving it. The real meaning of this statement you will realize when you participate in any forum. Even for some simplest of problems, you will see most beautiful solutions. And when you see a particular problem being approached in many different ways, your thinking towards a problem starts differing, starts getting multiple options. Also, the kind of learning which will happen here is something which you may not come across in any text book.

5. Develop a never repeating mindset: Tell yourself you will never do the same thing again. If you are doing the same thing again and again,  something is going wrong. Once you develop a mindset of this nature, you will automatically be more inclined towards automation or scripting. Think of ways which will minimize the effort, reduce the time needed to perform it. Any time you get something which you had done before, ask yourself one question: "How can I do it better than last time?". Next time, when you get it again, ask yourself: "What can I do so that I need not repeat the whole thing again next time?"

Happy Automating!!!

 

目录
相关文章
|
Unix Shell Perl
5 important things to follow to become good in shell scripting
http://unix-school.blogspot.in/2011/07/5-important-things-to-follow-to-become.
894 0
|
Unix Shell Go
10 good shell scripting practices
http://unix-school.blogspot.in/2011/07/5-important-things-to-follow-to-become.
943 0
|
Unix Shell Perl
5 important things to follow to become good in shell scripting
http://unix-school.blogspot.in/2011/07/5-important-things-to-follow-to-become.
1068 0
|
3月前
|
存储 安全 Unix
七、Linux Shell 与脚本基础
别再一遍遍地敲重复的命令了,把它们写进Shell脚本,就能一键搞定。脚本本质上就是个存着一堆命令的文本文件,但要让它“活”起来,有几个关键点:文件开头最好用#!/usr/bin/env bash来指定解释器,并用chmod +x给它执行权限。执行时也有讲究:./script.sh是在一个新“房间”(子Shell)里跑,不影响你;而source script.sh是在当前“房间”里跑,适合用来加载环境变量和配置文件。
|
3月前
|
存储 Shell Linux
八、Linux Shell 脚本:变量与字符串
Shell脚本里的变量就像一个个贴着标签的“箱子”。装东西(赋值)时,=两边千万不能有空格。用单引号''装进去的东西会原封不动,用双引号""则会让里面的$变量先“变身”再装箱。默认箱子只能在当前“房间”(Shell进程)用,想让隔壁房间(子进程)也能看到,就得给箱子盖个export的“出口”戳。此外,Shell还自带了$?(上条命令的成绩单)和$1(别人递进来的第一个包裹)等许多特殊箱子,非常有用。
|
6月前
|
Shell
Shell脚本循环控制:shift、continue、break、exit指令
使用这些命令可以让你的Shell脚本像有生命一样动起来。正确使用它们,你的脚本就能像一场精心编排的舞蹈剧目,既有旋律的起伏,也有节奏的跳跃,最终以一场惊艳的表演结束。每一个动作、每一个转折点,都准确、优雅地完成所需要表达的逻辑。如此,你的脚本不只是冰冷的代码,它透过终端的界面,跳着有节奏的舞蹈,走进观众——使用者的心中。
287 60
|
3月前
|
数据采集 监控 Shell
无需Python:Shell脚本如何成为你的自动化爬虫引擎?
Shell脚本利用curl/wget发起请求,结合文本处理工具构建轻量级爬虫,支持并行加速、定时任务、增量抓取及分布式部署。通过随机UA、异常重试等优化提升稳定性,适用于日志监控、价格追踪等场景。相比Python,具备启动快、资源占用低的优势,适合嵌入式或老旧服务器环境,复杂任务可结合Python实现混合编程。
|
9月前
|
关系型数据库 MySQL Shell
MySQL 备份 Shell 脚本:支持远程同步与阿里云 OSS 备份
一款自动化 MySQL 备份 Shell 脚本,支持本地存储、远程服务器同步(SSH+rsync)、阿里云 OSS 备份,并自动清理过期备份。适用于数据库管理员和开发者,帮助确保数据安全。