Search This Blog

Friday, October 10, 2008

Simple compiling with gcc

Having trouble with a simple compile:

gcc -o data data.c
/tmp/ccCAfDR5.o: In function `main':
data.c:(.text+0x4c): undefined reference to `exp'
collect2: ld returned 1 exit status

Then:

gcc -lm -o data data.c

And it works, because math.h is just a header file and you need to link with the math's library.

Tuesday, August 12, 2008

rsync with ssh between servers

Rsync quicky with ssh between servers.

rsync -av -n source dir/ server:/target dir -n for testing. nothing happens.

rsync -av source dir/ server:/target dir -n removed. Do it for real.

Also note:
Source dir has a "/" after it to copy its contents and not the directory itself.

Rsync installed in a different location on the remote host:

rsync --rsync-path=/opt/csw/bin/rsync -av -n source dir/ server:/target

Tuesday, June 10, 2008

Perl. Replace text in file.

Substitute text in a file in-situ

perl -i -pe 's/1234/4321/g' filename

-i edits file in-situ.
-p loops through each filename and prints out each line.

Convert Upper case to lower case

perl -i -pe 'tr/A-Z/a-z/' x