Tuesday, 21 February 2017

Linux Command

1. Delete last 23 lines from a file in unix.

Use sed, but let the shell do the math, with the goal being to use the d command by giving a range (to remove the last 23 lines):
sed -i "$(($(wc -l < file)-22)),\$d" file
To remove the last 3 lines, from inside out:
$(wc -l < file)
Gives the number of lines of the file: say 2196
We want to remove the last 23 lines, so for left side or range:
$((2196-22))
Gives: 2714 Thus the original sed after shell interpretation is:
sed -i 2174,$d file
With -i doing inplace edit, file is now 2173 lines!

OR
   awk '{buf[NR-1]=$0;}END{ for ( i=0; i < (NR-23); i++){ print buf[i];} }'

Wednesday, 1 February 2017

How to unlock the jobs

Through Unix:
'1.telnet to DS server machine as ds administrative account (dsadm or root for example);
2. cd to $DSHOME - to go to DSEngine;
3. source dsenv by “. ./dsenv”; (read as dot_space_dot_dsenv)
4. run “bin/uvsh” to enter TCL prompt
5. run “>LIST.READU EVERY”, are you able to find any lock for the project under Active RecordLocks? If yes, mark down the Userno for the command below;
6 run “>UNLOCK USER userno ALL”;
7. run “>LIST.READU EVERY” again to verify the lock for the user is gone;
8. repeat step 6 and 7 until all locks for the project is clear;
9. run “>LO” to exit TCL prompt.