Awk dumps.
Count number of bytes in multiple directories
I have been busy moveing (scp-ing/reorganising) large numer of databases over the network, this little awk script makes me able to count the number of bytes and thus check if my nighlty scp’s didn’t miss a byte. (or two)
/cygdrive/c/oracle/oradata/DB01/DB01
$ find . -name "*DBF" -exec ls -l {} \;
-rwxrwx--- 1 Administrators SYSTEM 10493952 Oct 9 16:49 ./DB01/DATAFILE/O1_MF_TEST_3HSWQYNH_.DBF
-rwxrwx--- 1 Administrators SYSTEM 104865792 Oct 9 16:49 ./EXAMPLE01.DBF
-rwxrwx--- 1 Administrators SYSTEM 293412864 Oct 9 16:49 ./P1PERG001.DBF
-rwxrwx--- 1 Administrators SYSTEM 104865792 Oct 9 16:49 ./P1PERG002.DBF
-rwxrwx--- 1 Administrators SYSTEM 272637952 Oct 13 08:34 ./SYSAUX01.DBF
-rwxrwx--- 1 Administrators SYSTEM 513810432 Oct 9 16:49 ./SYSTEM01.DBF
-rwxrwx--- 1 Administrators SYSTEM 20979712 Oct 13 08:36 ./TEMP01.DBF
-rwxrwx--- 1 Administrators SYSTEM 47194112 Oct 9 16:49 ./UNDOTBS01.DBF
-rwxrwx--- 1 Administrators SYSTEM 5251072 Oct 9 16:49 ./USERS01.DBF
/cygdrive/c/oracle/oradata/DB01/DB01
$ find . -name "*DBF" -exec ls -l {} \; | awk '
> BEGIN { BYTESRead more →
man: NAME: ls, ls – list directory contents
Display only directories in current directory
/cygdrive/c/temp $ ls -ld */
drwxr-xr-x+ 2 rz4tlj mkgroup-l-d 0 Sep 18 07:50 _backup_18-SEP-2007/
/cygdrive/c/temp $
Read more →
man: NAME: mailx, mail – interactive message processing system
send file as attachment
Use uuencode to encode a file and pipe it to mailx to be send as attachment (when you quickly need a file on your desktop it’s faster then ftp…)
uuencode file to mailx
$ uuencode file.txt file.txt | mailx -s file.txt <your-email-address>
$
In my environment the -r flag (return address) is needed since my mailserver is blocking mail without a known email address reply header.
uuencode file to mailx with -r flag
$ uuencode file.txt file.txt | mailx -s file.txt -r <your-email-address> <your-email-address>
$
Read more →
Here’s how I installed JDK on Centos (thanks to http://www.trading-shim.org/faq/?java)
Download
Go to http://java.sun.com/javase/downloads/index.jsp and download the desired file.
Extract the .bin file
[root@localhost tmp]# chmod 755 j2re-1_4_2_15-linux-i586-rpm.bin
[root@localhost tmp]# ./j2re-1_4_2_15-linux-i586-rpm.bin
Install the .rpm file
[root@localhost tmp]# rpm -Uvh j2re-1_4_2_15-linux-i586.rpm
Preparing... ########################################### [100%]
1:j2re ########################################### [100%]
Adjust environment
Finally add the path to the java executable in the /etc/profile file.
Test
$ java -version
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)
View symbolic links
In my environment a symbolic link is created in /usr/bin/java which points to /usr/java/default/bin/java.
$ which java
/usr/bin/java
$ ls -la /usr/bin/java
lrwxrwxrwx 1 root root 26 Jul 31 14:38 /usr/bin/java -> /usr/java/default/bin/java
$ ls -la /usr/java/
total 40
drwxr-xr-x 4 root root 4096
Read more →
man: NAME: nohup – run a command immune to hangups
nohup and SQL*Plus
Nohup and SQL*Plus can be easily used together:
$ nohup sqlplus -s remi/remivisser @update.sql &
[4] 14433
$ Sending output to nohup.out
$
$
Prevent password from being displayed in the ps list
$ export password=remivisser
$ nohup sqlplus -s remi/${password} @update.sql &
[8] 16768
$ Sending output to nohup.out
$
$
Read more →
man: NAME: pipe – create an interprocess channel
import from compressed export file
Example below demonstrates how to import ‘directly’ from a compressed file. Handy when you have not enough space on your mountpoint to unpack the file.
mknod pipe_db01 p
zcat exp.dmp.Z > pipe_db01 &
sleep 3
imp / file=pipe_db01 ...
Same as above but now for the other compression utilities.
(win)zip
unzip -p exp.dmp.zip > pipe_db01 &
gzip
gunzip < exp.dmp.gz > pipe_db01 &
gzip -cNf < pipe_db01 > exp.dmp.Z &
gunzip -c exp.dmp.Z > pipe_db01 &
cpio
cpio -icvdu < exp.dmp.cpio > pipe_db01 &
The other way around
Export to pipe and compress.
$ mknod c.pipe p
$ nohup compress < c.pipe > exp_DB01_2007-10-31.dmp.Z &
$ nohup exp system/$(cat .pwd) file=c.pipe owner=inotime log=exp_DB01_2007-10-31.log &
Read more →
man: NAME: find – find files
Find/Remove old files
Find files modified more then 365 days ago;
find . -mtime +365 -exec ls -l {} \;
Use touch to test
$ touch -t 197801130300 oldfile
$ find . -mtime +365 -exec rm {} \;
$ ls oldfile
ls: oldfile: No such file or directory
Read more →
awk
Awk dumps.
Count number of bytes in multiple directories
I have been busy moveing (scp-ing/reorganising) large numer of databases over the network, this little awk script makes me able to count the number of bytes and thus check if my nighlty scp’s didn’t miss a byte. (or two)
/cygdrive/c/oracle/oradata/DB01/DB01 $ find . -name "*DBF" -exec ls -l {} \; -rwxrwx--- 1 Administrators SYSTEM 10493952 Oct 9 16:49 ./DB01/DATAFILE/O1_MF_TEST_3HSWQYNH_.DBF -rwxrwx--- 1 Administrators SYSTEM 104865792 Oct 9 16:49 ./EXAMPLE01.DBF -rwxrwx--- 1 Administrators SYSTEM 293412864 Oct 9 16:49 ./P1PERG001.DBF -rwxrwx--- 1 Administrators SYSTEM 104865792 Oct 9 16:49 ./P1PERG002.DBF -rwxrwx--- 1 Administrators SYSTEM 272637952 Oct 13 08:34 ./SYSAUX01.DBF -rwxrwx--- 1 Administrators SYSTEM 513810432 Oct 9 16:49 ./SYSTEM01.DBF -rwxrwx--- 1 Administrators SYSTEM 20979712 Oct 13 08:36 ./TEMP01.DBF -rwxrwx--- 1 Administrators SYSTEM 47194112 Oct 9 16:49 ./UNDOTBS01.DBF -rwxrwx--- 1 Administrators SYSTEM 5251072 Oct 9 16:49 ./USERS01.DBF /cygdrive/c/oracle/oradata/DB01/DB01 $ find . -name "*DBF" -exec ls -l {} \; | awk ' > BEGIN { BYTESRead more →