-
Unix Basic Scripts
Whats the difference between ll and ls command?
Where can i get the set of commands in UNIX?
What is a shell?
If i am working on UNIX, What do i need to know?
Can you tell me some basic scripts in unix?
I know its long but urgent..
Question asked by visitor sameer
-
Junior Member
Re: Unix Basic Scripts
there is no command called as ll.
ls displays the files in current directory.
if you want set of commands in unix then press tab twice in the terminal.
for in detail about a particular command you can use man command
-
Junior Member
Re: Unix Basic Scripts
Hi,
You may refer to unixguide.net for basics of UNIX.
Here is an example of shell script which will show you disk space.
#!/bin/ksh
init()
{
day=`date |tr -s " " "-"|tr -s ":" "."`
lpat=/home/cmabct/vinod
mach=`uname -s`
myn=`uname -n`
mailp=/usr/sbin/sendmail
ids=${lpat}/dsk_ids.txt
logs=${lpat}/LOGS/dsk_${day}.txt
limit=${lpat}/LOGS/tmp_dsk.txt
##############################
#
sub="Subject: Disk Space Status($myn) on $day"
header="Filesystem kbytes used avail %used Mounted on"
if [ ! -d ${lpat}/LOGS ]
then
mkdir -p ${lpat}/LOGS
fi
if [ ! -f $ids ]
then
return 1
fi
>$logs
>$limit
}
cmds()
{
case $mach in
HP-UX) bdf | egrep "9[0-9]%|100%" > $limit;;
SunOS) df -lkF ufs > $logs
df -lkF tmpfs >> $logs
cat $logs | egrep "9[0-9]%|100%" > $limit
mailp=/usr/lib/sendmail;;
Linux) df -h | egrep "9[0-9]%|100%" > $limit;;
*) rm $logs $limit
return 1
esac
}
creatfile()
{
if [ -s $limit ]
then
> $logs
cat $ids >$logs
echo "$sub\n\n">>$logs
echo "$header">>$logs
cat $limit >>$logs
sleep 1
$mailp -t < $logs
else
rm $logs $limit
return 1
fi
}
mast()
{
init
if [ $? -ne 1 ]
then
cmds
fi
if [ $? -ne 1 ]
then
creatfile
fi
if [ $? -ne 1 ]
then
rm $limit
fi
}
Thanks,
Amit Shiknis
-
Junior Member
Re: Unix Basic Scripts
Hi,
You may refer to unixguide.net for basics of UNIX.
Here is an example of shell script which will show you disk space.
#!/bin/ksh
init()
{
day=`date |tr -s " " "-"|tr -s ":" "."`
lpat=/home/test/test
mach=`uname -s`
myn=`uname -n`
mailp=/usr/sbin/sendmail
ids=${lpat}/dsk_ids.txt
logs=${lpat}/LOGS/dsk_${day}.txt
limit=${lpat}/LOGS/tmp_dsk.txt
##############################
#
sub="Subject: Disk Space Status($myn) on $day"
header="Filesystem kbytes used avail %used Mounted on"
if [ ! -d ${lpat}/LOGS ]
then
mkdir -p ${lpat}/LOGS
fi
if [ ! -f $ids ]
then
return 1
fi
>$logs
>$limit
}
cmds()
{
case $mach in
HP-UX) bdf | egrep "9[0-9]%|100%" > $limit;;
SunOS) df -lkF ufs > $logs
df -lkF tmpfs >> $logs
cat $logs | egrep "9[0-9]%|100%" > $limit
mailp=/usr/lib/sendmail;;
Linux) df -h | egrep "9[0-9]%|100%" > $limit;;
*) rm $logs $limit
return 1
esac
}
creatfile()
{
if [ -s $limit ]
then
> $logs
cat $ids >$logs
echo "$sub\n\n">>$logs
echo "$header">>$logs
cat $limit >>$logs
sleep 1
$mailp -t < $logs
else
rm $logs $limit
return 1
fi
}
mast()
{
init
if [ $? -ne 1 ]
then
cmds
fi
if [ $? -ne 1 ]
then
creatfile
fi
if [ $? -ne 1 ]
then
rm $limit
fi
}
mast
Thanks,
Amit Shiknis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules