Welcome to Magical.DDNS.NeT Domain

Chat

Read Tao

Play Pacman

Software Repository

Linux Ditributions

Chatbot Source Code

SNES Emulator and Games

PS2 Emulator and Games

DNS Tools

Music

Docs

 

Programming in C Shell
Updated: Jun 2, 2024
echo " Enter the String"
read str
echo $str > str.txt
len = 'echo $str | wc -c'
len = 'expr $len -1'
c= 0 , w = 0 , s = 0 , i = 1
echo " Length of string = $len"
w = 'echo $str | wc - w'
c = 'echo $str | wc -c'

while [ i -le $ len ]
do
st = 'cut - c$I str.txt'
if ["str" = " "] then
s = 'expr $s + 1'
fi
i = 'expr $i + 1'
done

echo "Character = $c"
echo "Words = $w"
echo "Spaces = $s" 

netip=`/sbin/ifconfig eno1 | awk -F: '/inet / {print $1}' |awk '{print $2}'`;

#!/bin/sh
if [ $# -gt 0 ]
   then
      echo
      echo "Argument given "$*
      echo
      case $1 in
         -l) ls -al ~/.trashcan ;;
         -e) cd ~/.trashcan
             echo "Emptying Trashcan.."
             echo
             rm * ;;
          *) if [ -f $1 ] || [ -d $1 ]
                then
                   if [ -d ~/.trashcan ]
                      then
                         echo "Moving " $1 "to .trashcan"
                         echo
                         mv $1 ~/.trashcan/$1
                      else
                         echo "Trashcan doesn't exist. Creating it now.."
                         echo
                         mkdir ~/.trashcan
                         echo "Moving " $1 "to Trashcan"
                         echo
                         mv $1 ~/.trashcan/$1
                   fi
                else
                   echo $1 "Cannot be located in current path"
                   echo
             fi ;;
      esac
   else
      echo
      tput bold
      echo "Usage: \033[0;32m $0 [-l|e] || filename"
      echo "\033[0;40m "
      echo
fi



handy tput commands

    * tput bold - Bold effect
    * tput rev - Display inverse colors
    * tput sgr0 - Reset everything
    * tput setaf {CODE}- Set foreground color, see color {CODE} below
    * tput setab {CODE}- Set background color, see color {CODE} below

Colors {code} code for tput command
Color {code} 	Color
0 	Black
1 	Red
2 	Green
3 	Yellow
4 	Blue
5 	Magenta
6 	Cyan
7 	White

Color 	Code
Black 	0;30
Blue 	0;34
Green 	0;32
Cyan 	0;36
Red 	0;31
Purple 	0;35
Brown 	0;33
Blue 	0;34
Green 	0;32
Cyan 	0;36
Purple 	0;35

London Keys