certificates | database | DOS | hex | ksh | sed | sybase | Unix | vi |

certificates

Moving SSL Certs from IIS to Apache Instructions for exporting certs from IIS and converting them for use by Apache

database

www.sql-server-performance.com SQL Server performance tuning site, much of it applicable to other databases

DOS

dir /x lists DOS 8.3 filenames

hex

    0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
0  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015
1  016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031
2  032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047
3  048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063
4  064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079
5  080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095
6  096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111
7  112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
8  128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
9  144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
A  160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
B  176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
C  192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
D  208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
E  224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
F  240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

ksh

ksh case statement

Sample ksh case statement, based on the number of parameters passed into the script

case $# in
  1 )
    echo "Schedule: $1"
    ;;
  2 )
    echo "Schedule: $1"
    echo "Job     : $2"
    ;;
  3 )
    echo "Schedule: $1"
    echo "Job     : $2"
    echo "Script  : $3"
    ;;
esac

conditional block

Conditional block based on current directory

if [ $PWD != "/home/mark" ] ; then
  #do some stuff
fi

dates

Date stamp string in YYYYMMDD form (e.g., 20031031)

DATESTRING=`date -u +%Y%m%d`

filename

Use the basename command to get the name of a file without path

for filename in $somedir/blah_blah_????????.csv ; do
  $just_the_name = `basename $filename`
done

prompt

export PS1=`whoami`@`hostname`:' $ '

sed

loop example

The following is a sed script useful as a bcp cleanup script. The first line of the script deletes the first line of the file, eliminating the field headers. The commaRep loop replaces commas within quoted fields with double-pipes, for easy manipulation later. In the last three lines, all quotes are removed, remaining (field-delimiter) commas are replaced with double-tilde, and the double-pipes created earlier are converted back to commas. This script was created to clean up a data file wherein string fields are quoted when they contain commas and not quoted otherwise.

caveat: this script assumes that the first field in each row is never quoted.

1d

:commaRep
s/,"\([^"]*\),\([^"]*\)"/,"\1||\2"/g
t commaRep

s/"//g
s/,/~~/g
s/||/,/g

sybase

bcp

command line

Command line example for bcp out:
bcp $database..$table out $bcp_out_file -S$server -U$user -P$password -e$bcp_err_file -f$format_file >> $log_file
Command line example for bcp in:
bcp $database..$table in $bcp_in_file -S$server -U$user -P$password -e$bcp_err_file -f$format_file >> $log_file

format file

A little example format file. Version 10.0; 3 fields; field max-widths of 6, 11, and 11; delimiter of double-tilde; field 1 in data file does not correspond to any database column.
10.0
3
1 SYBCHAR 0 6 "~~"  0 DUMMY
2 SYBCHAR 0 11  "~~"  1 export_date
3 SYBCHAR 0 11  "~~"  2 as_of_date

docs


unix

cd - takes you to whatever directory you were in last, like the back button on a browser
<esc> <esc> acts like tab completion when using vi as shell editor (set -o vi) in ksh (not sure for which versions of ksh this applies)

vi

vi-editors.org

string substitution

The following vi command replaces occurrences of "target" with "replacement" from here to the end of the file.

:.,$s/target/replacement/