AWK
awk '{print $0}' ../../../modelsim/simdepends.mak_list : for full line
awk '{print $1}' ../../../modelsim/simdepends.mak_list : for first field
awk '{print $NF}' ../../../modelsim/simdepends.mak_list : for last field
awk '{print $(NF -1)}' ../../../modelsim/simdepends.mak_list : for last but one field
awk '{ for (i = NF; i > 0; --i) print $i }'
set errcnt = `awk 'BEGIN{e=0}/\*[eEfFiI]/{e++}END{printf("%d\n",e)}' cent_m2_sdf_compile.log`
cat ../../h1 | awk '{ print $1"\n" $2}'
cat ../../h1 | awk '{ORS = " "} { for (i = NF; i > 1; --i) print $i }'
cat ../../h1 | awk '{ for (i = 1; i <= NF; i++) print $i }'
cat ../../h1 | awk '{ if(NR = 2)}{ print $NR}'
awk '{ORS = "xxxx"}{print $0}' h2
for joining all the lines
awk 'length > 72' ../syn/cent.vhdl
awk '/module sdm_cobra_block_top/ , /endmodule/' sdm_cobra_block_top_scn.v

remove the newline character and then add the new line character :) the addition of \n is
not quite OK :)
awk '{ORS = ""}{print $0}' ~/misc/arraycache/ll1 | sed "s/[1-9]/\n/g"

awk '{ORS = ""}{print $0}' ~/misc/arrll1 | sed "s/z*/\n/g"

awk '{print $(NF-1)}' ../../../modelsim/simdepends.mak_list

SORT
sort -g -r -k2 -n time.report
Will sort numerically(-g), in reverse order(-r), as per field 2(-k2), -n(numeric sort)
ls -l | sort -n -k5 : this will give a listing arranged in order of file size

GREP
grep -e pat1 -e pat2 -m2 tb.vhdl
grep for pat1 OR pat2 and stop after second(-m2) match

find * | grep '\.v$'  to search for verilog files

-P is for perl-type patterns: good use is: to grep the newline(\n) char, see example below
grep -P 'guide_inv_push.*\n.*\n.*register' /homes/amittal/s5/hw/rtl/physical_lib/ramlib/tsmc_090_g/synopsys/*svf.txt

CUT
cat h1 | cut -c9- to print characters after 9th coloumn
cut -d: -f2,2 h2 to print the second field with ":" as a seprater
cut -d" " -f7- h2 for using space as a delimiter
cut -d" " -c 1-9  extracts the first 9 characters of each line

SED
sed "s/###/\"/user"/g" WWW.html
echo $home | sed "s/\//#/g" | sed "s/#/\\\//g"
sed "s/###/\"/user"\"/mittal"/g" WWW.html > zz
sed "s/###/\/user\/mittal/g" WWW.html > YY

Upper Case to Lower Case
ENTITYlc=`echo ${ENTITY} | sed 'y@ABCDEFGHIJKLMNOPQRSTUVWXYZ@abcdefghijklmnopqrstuvwxyz@'`

Lower Case to Upper Case
ENTITYuc=`echo ${ENTITY} | sed 'y@abcdefghijklmnopqrstuvwxyz@ABCDEFGHIJKLMNOPQRSTUVWXYZ@'`

WHILE
#!/bin/csh
@ i = 1
while ($i != 10)
echo $i
@ i ++
end

CRYPT
$ crypt key1 < file1 > crypted_file2

the above command used a key called key to crypt file1 and gives output
as crypted_file2
TO decrypt crypted_file2
crypt key < crypted_file2
 

EXAMPLE Script File
tables.csh
#!/bin/csh -f
\rm  -rf f0 f1 f2 f3 f4 f5
@ i = 12 ;
while ($i < 31)
#while ($i < 15)
#\rm f1

@ j = 1 ;
while ($j < 11)
echo "$i   *  $j     " >> f1
@ j ++
end
##echo "" >> f1

echo $i >> f0
@ i ++
end
cat f1 | bc > f3
paste f1 f3 > f4
awk '{print $1 "   " $2 "   " $3 "   =   "$4}' f4 > result
cat result | sed "s/*/X/g" >> res_fin
#\rm  f0 f1 f2 f3 f4 f5 result
 

find_list1_in_list2.csh
foreach i ( `cat cent` )
? set aa = `grep $i cent.vhdl`
? set bb = `echo $aa | awk '{print $1}'`
? if ($bb == "")  echo $i >> f1
? endif
? end

gen_num.scr
#!/bin/csh
@ i = 1
while ($i != 10)
echo $i
@ i ++
end

TEMPLATE SCRIPT
#!/bin/csh -f
set title = `basename $0`;
###########################
# FOR ARGUMENTS
###########################
  if ($#argv == 0) then
     set error = "Invalid number of arguments;At least One expected"
     echo "ERROR ($title)   :" $error;
#----------> set here the -h option to be displayed.
      exit
  endif
cat ~mittal/DOCS/tele | grep -i ^$argv[1]

DISPLAY Problems:
xhost +
setenv DISPLAY 'hostname'

rup to see load
related to rup rpc.rstatd
unix> rpc.rstatd
to make rup work

FONTS in LINUX
xlsfonts : to see the font list
xterm -font <font name from the list>
example
xterm -font lucidasanstypewriter-14

SETENV
setenv working_dir `pwd`
setenv unit $working_dir:t   sets unit to the last word in path name(tail)
setenv unit_path $working_dir:h  sets unit to the path minus the last word in path

Example:
if working_dir = /homes/amittal/misc then
$unit = misc
$unit_path = /homes/amittal



Auto FTP Script:

---------------------------------------------------------------------------------------
#!/bin/csh -f
set title = `basename $0`;
if ($#argv < 2) then
  set error = "Invalid number of arguments;At least One expected"
  echo "ERROR ($title)   :" $error;
  echo "Usage: unix> put <remote_dir_name> <local_file_name>"
  echo "Example: unix> put perl index.html"
  exit
endif
mv ~/.netrc ~/.netrc.bk
sed -e "s/dir/$argv[1]/g" -e "s/filename/$argv[2]/g" ~/.netrc_put > ~/.netrc
chmod 600 ~/.netrc
ftp vlsiip.com
------------------------------------------------------------------------------------------------

~/.netrc_put file is as follows
IMP: do not forget to include the last null line: otherwise it wont work.
------------------------------------------------------------------------------------------------

-------------------------------
machine vlsiip.com
login vlsiip
password guest123
macdef init
bin
cd www
cd dir
put filename
bye

--------------------------