Wicked Cool Shell Scripts: 101 Scripts for Linux, OS X, and UNIX Systems

By Dave Taylor

All pcs operating Linux, Mac OS X, or Unix-like working structures have a command line interface that offers clients a robust replacement to coping with their desktops and studying programming fundamentals. clients can write small courses, or scripts, that run within the command line "shell" to accomplish daily projects like renaming records or processing text.

Like the best-selling first variation, this revision of Wicked Cool Shell Scripts presents the whole resource code for over a hundred brief shell scripts that resolve universal difficulties, can be utilized to customize a user's computing setting, and are only undeniable pleasing. The instruments contain an interactive calculator, a inventory tracker, a password supervisor, a climate checker, and an internet site seek engine.

This revision comprises 22 brand-new scripts, a brand new bankruptcy on image-processing, and a set of scripts to paintings with cloud-based prone like Dropbox and iCloud.

Show description

Preview of Wicked Cool Shell Scripts: 101 Scripts for Linux, OS X, and UNIX Systems PDF

Best Linux books

Embedded Linux Primer: A Practical Real-World Approach (2nd Edition)

Up to the moment, whole assistance for constructing Embedded options with Linux   Linux has emerged as today’s no 1 working procedure for embedded items. Christopher Hallinan’s Embedded Linux Primer has confirmed itself because the definitive real-world consultant to development effective, high-value, embedded platforms with Linux.

The Official Ubuntu Book (5th Edition)

Ubuntu is a whole, unfastened working process that emphasizes group, aid, and straightforwardness of use with no compromising pace, strength, or flexibility. It’s Linux for humans, designed for everybody from desktop newbies to specialists. Ubuntu 10. 04 is the most recent release—more strong, extra versatile, and friendlier than ever.

Advanced Linux Networking

With more and more networks and mission-critical functions operating on Linux, method, and community directors has to be in a position to do greater than organize a server and depend upon its default configuration. this article is designed that can assist you in achieving a better point of competence. It specializes in strong recommendations and contours of Linux networking and gives you with the information you want to increase server potency, increase protection, and adapt to new standards.

Guide to Assembly Language Programming in Linux

Introduces Linux options to programmers who're conversant in different working structures similar to home windows XP presents finished assurance of the Pentium meeting language

Extra info for Wicked Cool Shell Scripts: 101 Scripts for Linux, OS X, and UNIX Systems

Show sample text content

Therefore, such a lot sysadmins have a suite of directions that they position on the most sensible in their log dossier research utilities, just like the subsequent: mv $log. 2 $log. three mv $log. 1 $log. 2 mv $log $log. 1 contact $log 154 C h ap te r 6 wcss_book03. e-book web page a hundred and fifty five Monday, December 15, 2003 11:27 AM If run weekly, this could produce a rolling one-month archive of log dossier details divided into week-size parts of information. notwithstanding, it’s simply as effortless to create a script that accomplishes this for all log records within the /var/log listing without delay, thereby relieving any log dossier research scripts of the weight. The script steps via each one dossier within the /var/log listing that fits a selected set of standards, checking every one matching file’s rotation agenda and last-modified date to determine if it’s time for it to be turned around. The Code #! /bin/sh # rotatelogs - Rolls logfiles in /var/log for archival reasons. # makes use of a config dossier to permit customization of ways often # each one log might be rolled. The config dossier is in # logfilename=duration # layout, the place period is in days. If, within the config # dossier, an access is lacking for a selected logfilename, # rotatelogs will not rotate the dossier extra usually than each seven days. logdir="/var/log" config="/var/log/rotatelogs. conf" mv="/bin/mv" default_duration=7 count=0 duration=$default_duration if [ ! -f $config ] ; then echo "$0: no config dossier chanced on. cannot continue. " >&2; go out 1 fi if [ ! -w $logdir -o ! -x $logdir ] ; then echo "$0: you do not have the best permissions in $logdir" >&2 go out 1 fi cd $logdir # whereas we need to exploit ':digit:' with the locate, many models of # locate do not aid POSIX personality type identifiers, for this reason [0-9] for identify in $(find . -type f -size +0c ! -name '*[0-9]*' \ ! -name '\. *' ! -name '*conf' -maxdepth 1 -print | sed 's/^\. \///') do count=$(( $count + 1 )) # seize this access from the config dossier duration="$(grep "^${name}=" $config|cut -d= -f2)" Sy s t em A dm in is t ra ti on : Sy s t em M ai nt en a nc e a hundred and fifty five wcss_book03. booklet web page 156 Monday, December 15, 2003 11:27 AM if [ -z $duration ] ; then duration=$default_duration elif [ "$duration" = "0" ] ; then echo "Duration set to 0: skipping $name" proceed fi back1="${name}. 1"; back2="${name}. 2"; back3="${name}. 3"; back4="${name}. 4"; # If the main lately rolled log dossier (back1) has been converted inside # the categorical quantum, then it is not time to rotate it. if [ -f "$back1" ] ; then if [ -z $(find \"$back1\" -mtime +$duration -print 2>/dev/null) ] then echo -n "$name's latest backup is more moderen than $duration " echo "days: skipping" ; proceed fi fi echo "Rotating log $name (using a $duration day schedule)" # Rotate, beginning with the oldest log if [ -f "$back3" ] ; then echo "... $back3 -> $back4" ; $mv -f "$back3" "$back4" fi if [ -f "$back2" ] ; then echo "... $back2 -> $back3" ; $mv -f "$back2" "$back3" fi if [ -f "$back1" ] ; then echo "... $back1 -> $back2" ; $mv -f "$back1" "$back2" fi if [ -f "$name" ] ; then echo "... $name -> $back1" ; $mv -f "$name" "$back1" fi contact "$name" chmod 0600 "$name" performed if [ $count -eq zero ] ; then echo "Nothing to do: no log records large enough or sufficiently old to rotate" fi go out zero to really be beneficial, the script must paintings with a configuration dossier that lives in /var/log, which permits assorted log records to be set to various rotation schedules.

Download PDF sample

Rated 4.89 of 5 – based on 3 votes