Learning Unix Scripting

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:

#!/usr/bin/ksh

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.
ben1211Asked:
Who is Participating?
 
droydenCommented:
For your date script:


#!/bin/sh
 
date --date '1 days ago'
 
Check these few links for ksh scripting:
 
http://www.well.ox.ac.uk/~johnb/comp/unix/ksh.html
http://www.injunea.demon.co.uk/pages/page203.htm
http://www.livefirelabs.com/korn_shell_scripting_sample/main.htm

Open in new window

0
 
ozoCommented:
man ksh
0
 
Ken FayalCTOCommented:
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
woolmilkporcCommented:
0
 
ben1211Author Commented:
droyden....i've tried your command date --date and it doesn't work. By they way, I'm using HPUX 11.
0
 
droydenCommented:
Please see this script for examples:
http://mirrors.develooper.com/hpux/caljd-2.23.sh

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




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

Open in new window

0
 
ben1211Author Commented:
hi Droyden....as mentioned, I'm a beginner. Thanks for the script, but I can hardly understand it.
0
 
kenny555Commented:
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)

#!/bin/bash

echo `(export TZ=PST+24; date)`
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.