Script to Store given command and execute them

in Categories Academic last updated April 3, 2008

Write script to store the following command and execute them:
a) date
b) echo “Message”
c) cal

#!/bin/bash
# Script to Store given command and execute them
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
date
cal
echo "Hello Friends"

Shell script to find the number of files present in the current directory without using WC command

in Categories Academic last updated October 14, 2009
#!/bin/bash
# Shell script to find the number of files present in the current
# directory without using WC command.
# NOTE/TIP:
# If allowed to use WC command then it should be as follows:
# ls | wc -l
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
FILE="/tmp/count.txt"
 
echo -n "Enter directory name : "
read dname
 
ls $dname > $FILE
 
echo "No of files in directory : $(grep [^*$] $FILE -c)"
rm -f $FILE