Archive for May, 2009

Renaming Files In Linux

In a previous post, I wrote about converting strings from camelCase to undescore delimited format.

In this post, we’ll do the same but for file names. We’ll use the command line program “rename” for this purpose.
Here we go:

1. Convert all file names in current directory which are of the form “myFileName” or “MyFileName” into the form of “my_file_name”:

1
rename 's/(.)([A-Z])/$1_\l$2/g' * && rename 's/([A-Z])/\l$1/g' *

2. Convert all file names in current directory which are of the form “my_file_name” into the form “myFileName”:

1
rename 's/([a-z])_([a-z])/$1\u$2/g' *

3. Convert all file names in current directory which are of the form “my_file_name” into the form “MyFileName”:

1
rename 's/([a-z])_([a-z])/$1\u$2/g' * && rename 's/^([a-z])/\u$1/g' *

Enjoy ;)

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: ,

Saturday, May 30th, 2009 Bash 1 Comment

Convert camelCase to Underscores Using sed

This short post deals with converting strings of the form camelCase or CamelCase into camel_case, and vice versa. These are three different popular naming conventions for variable/function/class names.

Convert CamelCase or camelCase to camel_case:

1
sed -e 's/\([A-Z]\)/_\l\1/g' -e 's/^_\([a-z]\)/\1/g' file.txt

Convert camel_case to camelCase

1
sed -e 's/_\([a-z]\)/\u\1/g' file.txt

Convert camel_case to CamelCase:

1
sed -e 's/_\([a-z]\)/\u\1/g' -e 's/^\([a-z]\)/\u\1/g' file.txt

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: ,

Saturday, May 30th, 2009 Bash 5 Comments

Browse the Linux Kernel Source with LXR

LXR (stands for Linux Cross-Reference), is a great tool which indexes the source code of the Linux Kernel and allows you browse the source in your favorite browser (Firefox), with quick references for all functions/files referenced in that code. (it’s not limited to use in Linux Kernel though, and can be used to index any large project’s source code).

Whenever I need to touch the Linux Kernel code, I first open a new tab with LXR, another with Google ready to work, and a shell terminal ready for grep queries.

› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , ,

Tuesday, May 12th, 2009 Linux Kernel 6 Comments

Sed and AWK – A quick reference

Sed (Stream Editor) and AWK (First letters of the surnames of its authors) are very powerful *nix tools for manipulating strings and text files. They combine the power of regular expressions with the power of a programming language for this aim.
Here are two quick references for doing many operations with a one-line code of sed and AWK. (Both are by the same author – Eric Perment):
› Continue reading

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Tags: , , ,

Saturday, May 9th, 2009 Bash No Comments
my email
my photo
Hi,
My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
I'm a Verification Engineer in Mellanox Technologies Ltd.
I love Linux, the Command Line and the OpenSource Community.
I used to write Poems (Arabic) when I was able to find time for this.
May 2009
S M T W T F S
« Mar   Jun »
 12
3456789
10111213141516
17181920212223
24252627282930
31  
SEO Powered by Platinum SEO from Techblissonline

Twitter links powered by Tweet This v1.7.4, a WordPress plugin for Twitter.