Glass Onion Blog

Cheat sheets, post-its and random notes from the desk of a programmer

Posts Tagged ‘linux’

Linux: Renaming multiple files from command line

Posted by walrus on September 12, 2008

How to rename multiple files at a shell prompt under Linux? The rename command is quite useful.

Rename command usage:

rename oldname newname *.files

Some examples:

Rename all *.abc file as *.xyz:

$ rename .abc .xyz *.abc

Remove .txt file extension:

$ rename 's/\.txt$//' *.txt

Convert all uppercase filenames to lowercase:

$ rename 'y/A-Z/a-z/' *

Posted in Software, linux | Tagged: , , , , | Leave a Comment »

Linux: Setting JAVA_HOME for a single user and all users

Posted by walrus on July 21, 2008

Here is how to setup JAVA_HOME and PATH environment variables for a single user or all users on Fedora Linux system

Setting JAVA_HOME and PATH for a single user

# vi ~/.bash_profile
# export JAVA_HOME=/opt/jdkx.x.x_xx
# export PATH=$PATH:$JAVA_HOME/bin

Setting JAVA_HOME and PATH for all users

# vi /etc/profile
# export JAVA_HOME=/opt/jdkx.x.x_xx
# export PATH=$PATH:$JAVA_HOME/bin

Posted in Software, Technology, java, linux | Tagged: , , | Leave a Comment »

Linux – How to find out which Shell you are using?

Posted by walrus on July 21, 2008

Here are three quick ways to find out which shell you are currently using:

Method 1:

command:

# echo $SHELL

output:

/bin/bash

Method 2:

command:

# echo $0

output:

-bash

Method 3:

command:

# ps -p $$

output:

 PID TTY               TIME CMD
1447 tty1          00:00:01 bash

Posted in Software, Technology, linux | Tagged: , , | 1 Comment »

Creating Linux style symbolic links in Windows Vista

Posted by walrus on July 18, 2008

Windows Vista supports symbolic links (soft links). One way of creating these links is using the command line utility called MKLINK.

Run Command Prompt and type the comman MKLINK.

If the system warns saying…“You do not have sufficient privilege to perform this operation”. Run the Command Prompt as Administrator

Usage:

MKLINK [[/D] | [/H] | [/J]] Link Target
        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    specifies the new symbolic link name.
        Target  specifies the path (relative or absolute) that the new link
                refers to.

Example: To create a directorty link called src what points to c:\users\foo\src

     mklink /D src c:\users\foo\src
Thats it!

Posted in Software, Technology, Windows, linux | Tagged: , , , | 1 Comment »