Pages

Saturday, March 19, 2011

Some shell script Experiments

1. Capture Ctrl+c Signal using Shell script

trap 'echo pressed c' 2

read f


2. Getting current PID using shell script

#!/bin/sh

echo $$

3. Use of arrays in shell script

newmap['name']="Abc"

newmap['designation']="SSE"

newmap['company']="xyz"


echo ${newmap['company']}

echo ${newmap['name']}

echo "after"

newmap=(Abd SSE HRD)

echo ${newmap[0]}

echo ${newmap[1]}

echo ${newmap[2]}

for i in newmap

do

echo $i

done

No comments:

Post a Comment