Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 787
  • Last Modified:

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.
0
ben1211
Asked:
ben1211
6 Solutions
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now