A successful Linux shell script

Source: Internet
Author: User

Linux shell scripts are more or less affecting the work of many programmers. There are many questions that need to be answered in depth. Next, let's take a look at the introduction to the Linux shell script. And you will gain some benefits.

Sppence Murray is one of the Linux developers and has long been a strong supporter of UNIX. This article describes the basic technology used by Murray and his colleagues in Codemonks Consulting in daily Linux development and application service work: shell script, I believe that all Linux developers will benefit from this useful and common technology.

Spence Murray is one of the founders of Codemonks Consulting. Since the earliest code written on SunOS in 1980s, Spence Murray has been committed to UNIX/Linux development. Since then, he has worked in IBM's AIX and SGI Irix to write cross-platform UNIX code for a long time, including HP/UX, Irix, Solaris/SunOS, sco unix, various BSD, MacOS X, and of course Linux. He has done everything from graphics/Video device drivers to UI code. The cross-platform Code Compiled by Murray includes the X Window System Xserver code and the core browser code as part of Netscape Navigator.

The most common Linux tools used by Murray are vi, bash, and Emacs. "Whether I am writing C, C ++, Java, shell scripts, or HTML, I switch back and forth among these tools most of the time," he said.

Linux shell script secret weapon

Murray believes that for a Linux developer, shell is a powerful software development tool, which is not rated as much. "In every job I do, I need to use shell scripts to quickly read and modify common text or write code," he said. "It's lightweight and fast, and its short Command makes moving code back and forth a fast and painless process. As an editor, it will soon become the second instinct ".

For Murray, Emacs emerged later as a development tool. "In the early 1990s S, I tried to use Emacs as an IDE and soon switched to the foyer. Emacs is very powerful. In those days, I will always open an Emacs window and often open dozens of source files, each has the context I edited, the debugging session using gdb, And the bash script running in different source directories. There is a lot of information about Emacs, which can be said to be a terrible tool... In addition, you can run Emacs on any system that you want to spend time developing.

Since the first time using the simple environment vi supported by SunOS In The Middle Of 1980s, the Emacs editor has become a standard tool for Murray. "It can be used on UNIX of various genres, which is one of the main reasons I chose for cross-platform development," he said.

Linux developers: Understand your Linux shell script

Murray requires that you understand your shell. "Bash, tcsh, and csh-shell are your most basic software development tools," he stressed. "It can do a lot of amazing things. All work depends on it ...... And its powerful functions ". As an example to illustrate the powerful functions of common shell scripts, there is a file that can be downloaded in the references section, including a set of scripts, used to obtain updated RPM packages released by Red Hat and merge them into the original and customized packages. After downloading and decompressing the file, you can find the script in the/developerworks/rpm_update_scripts directory. The final result is a directory that includes the latest version of all software packages and an hdlist file for network installation upgrades.

The following code snippet implements automatic updates to the Red Hat RPM package to create an installable version that uses the latest RPM. This is a basic step for anyone who maintains a public Linux server. For us, we usually maintain a large number of network services on many public Linux servers. The following are some scripts that can automatically update the latest security and functions.

The script below demonstrates that common shell programming technology can be widely used in various system configurations and program design applications. The script uses the bourne shell, which is the most common shell in different UNIX systems. This ensures that these very lightweight codes can be slightly modified or used on different UNIX systems without modification. It is easy to modify the Red Hat software package specification to apply it to other Linux releases.

Freshen. sh update the RPM package on the site using the specified RPM ftp to update the original RPM list. Execute the filter to replace the updated RPM package. Finally, the long release list is updated based on the new RPM Software Package obtained from the image Update site.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.