Learning Unix Scripting

Posted on 2009-02-17
Last Modified: 2013-12-06
I am very new to Unix and I am looking to improve myself. I would like to learn more command and especially more on how to write Unix Scripts. I know there are a few kinds of Unix scripts written. The ones that are used at my work place starts off with:


Could you point me to resources where I can learn more please? I've not been able to find much.

I am also looking for a Unix Script that produces yesterday's date.
Question by:ben1211
    LVL 7

    Accepted Solution

    For your date script:

    date --date '1 days ago'
    Check these few links for ksh scripting:

    Open in new window

    LVL 84

    Expert Comment

    man ksh
    LVL 9

    Assisted Solution

    by:Ken Fayal
    LVL 68

    Assisted Solution

    LVL 16

    Assisted Solution

    by:Bryan Butler

    Author Comment

    droyden....i've tried your command date --date and it doesn't work. By they way, I'm using HPUX 11.
    LVL 7

    Expert Comment

    Please see this script for examples:

    Usage would be (make sure that its in the PATH (ie /bin) and called

    DT=$( $( -p 1))
    echo "The date yesterday was: ${DT}"

    Open in new window


    Author Comment

    hi mentioned, I'm a beginner. Thanks for the script, but I can hardly understand it.
    LVL 38

    Assisted Solution

    LVL 2

    Assisted Solution

    There are so much to learn on Unix scripting.
    First, pick your flavor.
    If you like C-like stuff, then pick csh or tsch for procedural execution, one line after another.

    If you need your script to do loop or sub function,   then I suggest bash or ksh

    If you need to parse files ... go with perl.  
    The rule of thumb is, if you need to write something bigger than a makefile, use perl.

    Here is your yesterday date script in bash shell:
    (replace PST with your time zone)


    echo `(export TZ=PST+24; date)`

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    Title # Comments Views Activity
    sddpcm 1 60
    Syslinux UEFI USB boot 4 185
    unix scripting question 1 70
    Expand a partition in Centos 7 Linux with Virtualmin 1 38
    My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (, discussed installing the Solaris Operating S…
    Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now