$ cat test
first:second
one:two
$ sed 's/\(.*\):\(.*\)/\2:\1/' test
second:first
two:one
Wednesday, June 22, 2005
sed: Swap two words around
Saturday, June 18, 2005
Friday, June 17, 2005
Strip off file extension
Or
${filename%.*}
Example:
$ filename="Foo.java"
$ echo ${filename%.java}
Foo
Or
$ filename=$(basename Foo.java .java)
Sunday, June 12, 2005
Set cdable directories
In .bashrc :
shopt -s cdable_vars
export bin=~/bin
export doc=~/files/MyDocs
*Note: It doesn't seem to work if it's in.bash_profile .
shopt -s cdable_vars
export bin=~/bin
*Note: It doesn't seem to work if it's in
Friday, June 10, 2005
Searching the command history
1) Press Ctrl-R at the shell
2) Begin typing a few letters of the command containing the string you typed so far
3) Press Enter to execute the command