I have come across with some new text commands in a book that I hadnt seen before .These are : fmt, tac, join,(un)expand,split. Among them I am very impressed by join which makes an Sql-like join between 2 (or more I guess) files which is very useful.Here an example:Suppose you have two files whose one columns are equal (or contains same information, like an id column of sql) and you want to join these files with respect to tht column.You simply write
join file1 file2 if the first columns of file1 and file2 are common. If the common column is not first you can define it by -1 clnr or -2 clnr switches. There is also an -o switch which is useful for formatting output.To print the first and second columns from file 1 and say third column from file2 we write -o 1.1,1.2,2.3 .Here is a complete example
join file1 file2 -j 3 -o 1.1,1.3,2.2 .
Split is another nice command which splits larger files into smaller ones to easily handle them (when uploading,transferring etc). You just write split -b 32K file where -b 32K means the size of the parts is 32K.Then to join them you can write simply cat x* > newfile.
Tac is reverse of cat and does the reverse job.
Expand converts tab to spaces and unexpand does the vice versa.
Fmt is about formatting the output.
Çarşamba, Ağustos 05, 2009
Pazartesi, Ağustos 03, 2009
Fring ile cep telefonunuzdan sip gorusmesi yapin
Cep telefonunuz ile internette dolasabiliyor musunuz? O zaman Java destekli bir telefona sahipseniz www.fring.com dan indireceginiz program sayesinde telefonunuzun sip ozelligi olmasa bile cebinizden sip gorusmesi yapabiliyorsunuz.Internet uzerinden cok ucuza gorusun.
Cuma, Temmuz 17, 2009
Sed grouping and paranthesis
I forgot how to group regex in sed and also using \ with paranthesis.
Here is a summary
1-If you group a regex with () then \1,...,\10 is the way to call them.
2-You must put \'s before any paranthesis inside sed like this
sed "s/\([0-9]\{1,3\}),\([0-9]\{1,3\}/\1.\2/g"
This sed makes two groups [0-9]\{1,3\} representing the digits before and after ",". And makes the comma between them a point ".". And prints the result.
This is the page which inspired me
http://www.catonmat.net/blog/sed-one-liners-explained-part-one/
Here is a summary
1-If you group a regex with () then \1,...,\10 is the way to call them.
2-You must put \'s before any paranthesis inside sed like this
sed "s/\([0-9]\{1,3\}),\([0-9]\{1,3\}/\1.\2/g"
This sed makes two groups [0-9]\{1,3\} representing the digits before and after ",". And makes the comma between them a point ".". And prints the result.
This is the page which inspired me
http://www.catonmat.net/blog/sed-one-liners-explained-part-one/
Perşembe, Haziran 04, 2009
FreeNAS On Qemu
I have an openbsd on an old P2 computer. I use this box as a nfs and dns server for myself and some friends on my network. Because my friends have windows pcs I was in search of a way of sharing my music and files on this box. I found mt-daapd (now called firefly media server) as a solution. It works fine for sharing music with DAAP a protocol used by IPods. On windows there are programs Songbird(with an extesion), Itunes which are able to understand DAAP. For sharing files and many other things I knew FreeNAS is a nice solution but I didnt have chance to try. I thought it is time to try it and planned using it with QEMU. I compiled QEMU from the ports of my openbsd 4.1 without any problems.Then I created an image file for FreeNAS by this
$ qemu-img create FreeNas.img 1GB
Then I used FreeNas iso file downloaded from www.freenas.org and used it to install by this
$ qemu -localtime -hda FreeNas.img -cdrom /path/FreeNas.iso -boot d
After installing FreeNas as described in its manual, I closed FreeNas and started the virtual machine by this
$ qemu -localtime -hda FreeNas.img -net user -net nic
and configured ethernet device with dhcp to enable port forwarding. Then close and start the virtual machine with this
$ sudo qemu -localtime -hda FreeNas.img -net user -net nic -redir tcp:80::80
and voila. Now it is configured and works like a charm. Now it is enough to point browser to ip adress of my openbsd box to reach the admin web gui.
Çarşamba, Mayıs 13, 2009
VirtualBox Services on Guest
When you install on Virtualbox a guest operating system with NAT (connection between guest and host provided by nat) and you want to provide a service on guest, then you can make port forwarding to reach this service from outside.
Host: 192.168.2.x on network 192.168.2.0
Guest: 10.0.2.15 on network 10.0.2.0
Lets say the service we want to provide on Guest is rdp.
We need to make these commands
VBoxManage setextradata "GuestVM"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "GuestVM"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" portnumber(ie,3389)
VBoxManage setextradata "GuestVM"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" portnumber(ie,say 3389 or anything other which is availabel on host)

Host: 192.168.2.x on network 192.168.2.0
Guest: 10.0.2.15 on network 10.0.2.0
Lets say the service we want to provide on Guest is rdp.
We need to make these commands
VBoxManage setextradata "GuestVM"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "GuestVM"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" portnumber(ie,3389)
VBoxManage setextradata "GuestVM"
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" portnumber(ie,say 3389 or anything other which is availabel on host)
Çarşamba, Nisan 22, 2009
An Awk feature
I was trying to use sub (or gsub) function in awk to delete an \r from the end of line. For that purpose I used
dum=sub(/\r/,"",$0)
and thought that the variable "dum" will be filled with the changed value of $0. But I realised that sub function only make the change and returns 0,1 accordingly. So I wrote like this
sub(/r/,"") ; x=$0;

dum=sub(/\r/,"",$0)
and thought that the variable "dum" will be filled with the changed value of $0. But I realised that sub function only make the change and returns 0,1 accordingly. So I wrote like this
sub(/r/,"") ; x=$0;
Kaydol:
Yorumlar (Atom)