Thursday, December 28, 2006

Substr in unix/linux shell script

Linux: expr substr 1 3
Solaris: awk '{print substr($1, 1,3}' (the expr in solaris does not support substr)

Tuesday, December 26, 2006

Access windows file server from Linux

1. Use smbclient (a ftp-like client allows you put/get file)

smbclient -U Windows_Domain\\user //windows_file_server_name/dir

it prompts for your windows password

2. Mount the file server

mount -t cifs '//windows_file_server_name/dir' /mnt/mount_point -o username=Windows_Domain\\user,rw,iocharset=utf8

After typing your windows password, you can access the files on the windows server
cd /mnt/mount_point
ls -l

The above are tested in FC6

Monday, December 11, 2006

Sort tab delimited Japanese Data (unix)

sort -t ******** # push a tab key here, it wouldn't accept \t

in zsh, it will be a no-go because tab is assigned for auto-completion. You may need to create a shell file and put the command in.

the file would like

sort -t " " ......

In order to sort Japanese Data, you have to set LANG=jp_JP.UTF-8 for Linux
For Solaris LC_CTYPE=jp_JP.UTF-8 will do the thing.