Handy Linux/Unix

Commands and Scripts

a Menu Page

Home > RefInfo menu > Computer topics menu >

This Handy Commands and Scripts Menu page

! Note !
More sample commands and scripts and links may be added
to these pages --- if/when I revisit or use these pages.

< Go to Table of Contents, below. >
(Skip the following Introduction.)

INTRODUCTION :

Below are links to samples of shell commands and shell-script code --- grouped in several categories:

  • commands for setting shell command-line prompts ---
    in user 'run control' or 'profile' files

  • commands for setting command aliases ---
    in user 'run control' or 'profile' files

  • more than 450 handy scripts available in a system called 'feNautilusScripts' --- scripts for use within a GUI file manager --- which can be used to easily select one or more files for input to a script

  • 'batch' HTML GENERATION scripts
    (to display image files or play audio files or show sample script/program code or show sample HTML templates or...)

    NOTE:
    These are old scripts written around 2011 that may not display nicely in web browsers in cellphones or in web browsers on tablets held in 'portrait' orientation. The following set of HTML-generation scripts are written to display well in cellphones.

  • HTML GENERATION scripts
    (to display image files or video/audio files)
    (using a small CSS file and a small JavaScript file to provide good display on cellphones)

  • script 'snippets' showing handy short-and-sweet commands using utility commands such as 'awk', 'df', 'du', 'ls', 'sed', etc.

  • some menus of 'complete scripts' --- that use 'awk' or 'sed' or 'sort'

  • links and direction to sources of more shell script code [at the bottom of this page]

Use the table-of-contents below to go to code samples in these categories.

Table of Contents:

(links to content on this page --- or on other pages of this site)

  • How to set shell command PROMPTS (especially PS1)
    in user 'run control' or 'profile' files

  • How to set command ALIASES
    in user 'run control' or 'profile' files

  • handy 'FE Nautilus Scripts'
    for Audio, Image, Video processing,
    as well as for Selected-File Listings and other utility functions
    (for use with GUI file managers - originally Gnome2-Nautilus;
    can be used with MATE-Caja file manager and others)

  • 'ffmpeg' Script Examples
    for editing of movie files
    (clipping, cropping, converting, audio-volume-change, audio-extraction)

  • sample 'batch' HTML GENERATION scripts
    (to display image files -OR- play audio files -OR- show sample HTML templates -OR- show sample script/program code -OR- ...)

    NOTE:
    These are OLD scripts written around 2011 that may not display nicely in web browsers in cellphones or in web browsers on tablets held in 'portrait' orientation. The FOLLOWING set of HTML-generation scripts are written to display well in cellphones.

  • sample HTML GENERATION scripts
    (to display a 'batch' of image files or video/audio files)
    (using a small CSS file and a small JavaScript file to provide good display on cellphones)

  • a collection of command or script 'snippets'
    using commands such as awk, cut, date, df, du, find, grep, ls, sed, tr, xargs

  • a menu of 'complete' 'awk' script examples

  • a menu of 'complete' 'sed' script examples (someday?)

  • a menu of 'complete' 'sort' script examples (someday?)

  • Links to web tutorials and sources of script/alias code
    [below on this page]


  • a Menu of Web Searchers (to find more code examples)

End of Table of Contents. See notes below.

Some code notes :

Generally, in ALL my scripts, I use double-# (##) to indicate a true comment. That is, it is not an executable statement and should never be de-commented.

I use single-# (#) to indicate an executable statement that has been commented. Typically this is because I might want to decomment the statement when doing testing of the script in a terminal window. Generally, the statement should be re-commented --- or a neighboring statement should be commented --- when done testing.

I do not try to make one-liner scripts, nor do I try for the ultimate in processing efficiency. (But I am aware of several things to avoid that would make scripts run as slow as molasses.) Rather, I try to make the scripts readable (to me). At the same time, they generally execute quite rapidly --- as rapidly as the target files and the applications called allow, even on a directory containing more than one hundred files.


Shell considerations :

Most of these samples are intended to run with the Bourne or the Korn shells (command interpreters), as well as with the Bash command interpreter. Most of these samples employ commands (and their parameters) available to all three interpreters, so the scripts (and aliases) will generally run in any of these three interpreters.

In fact, the Korn and Bash interpreters are offshoots of the Bourne command interpreter.

Most of my scripts start with the line "#!/bin/sh". In many Linux distros (like Ubuntu), /bin/sh is a symbolic-link (aka 'soft link') back to /bin/bash or /bin/dash, where dash is basically a subset of the bash interpreter. If /bin/sh does not exist in your Linux distro, you can simply create the symbolic link by issuing (as root) the command

ln -s /bin/bash /bin/sh

where /bin/bash represents the location of the bash interpreter program.

Brief BACKGROUND on shell scripting :

This page assumes the reader is familiar with shell scripting.

However, for a basic introduction to Linux/Unix shell scripting, try the Wikipedia page on Shell_scripting.

In particular, see the Wikipedia page on the Bourne_shell.

You may find it helpful to follow some links on those pages.


Shell scripting TUTORIALS / REFERENCES :

There are many web sites that provide tutorials for shell scripting. Someday I may provide a separate web page of such sites. Unfortunately, many such sites go dead quite rapidly.

In the meantime, here are a few links to some tutorials :

A problem with tutorials is that they often contain many code 'snippets' but not many complete code samples that accomplish very much. To accomplish much, they would have to be too long for a tutorial.


SOURCES of Shell Script code samples :


Web Archives:

Many instructive shell script code samples are available through code archive web sites such as

I found the Shelldorado archive by doing a web search on 'strings' like :

I used the keywords 'shell script' because there are many other scripting languages, such as Perl, Python, and Tcl/Tk.

For Tcl-Tk scripts, see (old) Tcl-Tk samples pages available via the 'Tcl-Tk' section of my Computer Topics (Ref Info) page --- or see the 'tkGooies' at freedomenv.com --- or see my Tcl-Tk LINKS page available via the Home page of this site.


The code samples on my script-samples pages --- such as the 'feNautilusScripts' Code Samples pages --- may be, in some cases, too large for tutorials. But they have much to offer in the way of examples of working (that is, de-bugged ... to a pretty good extent) shell scripting code for shell-script developers 'of all stripes'.


SCRIPT-CODE WEB SEARCHES:

Since many shell scripts start off with a call to the '#!/bin/sh' or '#!/bin/ksh' or '#!/bin/bash' interpreter, one way to find code samples is to do web searches on keyword strings such as

NOTE:
Since web searchers typically replace special characters in your search strings with a blank character (and seemingly replaces leading blanks by a null character),

  • a search on "#!/bin/sh"
  • a search on "bin/sh"
  • a search on "      bin sh", and
  • a search on "bin sh"
will usually return the same 'hits'. So "bin sh" will probably suffice.

Forums:

Another handy source of help and code samples for shell scripting is forums, such as

Forums come and go (or just fade away), so some of these will probably be dead links.

You could try a web search on 'strings' like :


Books:

The most practical and useful book on shell scripting that I have ever found is the O'Reilly book, 'Unix Power Tools'.

If you can't find an answer to your shell scripting question in this book, you will probably have to do a web search.

Bottom of this
Handy Linux/Unix Commands & Scripts Menu page.

To return to a previously visited web page location, click on the Back button of your web browser a sufficient number of times.

OR, use the History-list option of your web browser.

OR ...

< Go to Table of Contents, above. >

< Go to Top of Page, above. >

Page history:

Page was created 2009 Oct 28.

Page was changed 2015 Feb 24.

Page was changed 2017 Sep 18.
(An extensive reorganization of this page.)

Page was changed 2018 Jun 16.
(Added link to menu of 'awk' script examples.)

Page was changed 2018 Sep 01.
(Added css and javascript to try to handle text-size for smartphones, esp. in portrait orientation.)

Page was changed 2021 Jun 18.
(Added a new HTML-generation-scripts menu option --- providing sample scripts to display a batch of images or video/audio files, using a bit of Javascript and CSS to provide good display of the HTML on cellphones in portrait orientation.)

Page was changed 2021 Jul 23.
(Added a link to an 'ffmpeg Script Examples' page.)