ManthanHD

Findings, thoughts and observations from the eye of a Software Engineer.

  • Findings
  • Agile
  • Thoughts
  • Educational
  • Skills
  • Random

Month: February 2012

Using SCLC (Source Code Line Counter)

24th February 2012 / Leave a Comment

Well, it is really very simple. Here you go:

  1. Download the file. You can get it from here.
  2. Double click it. It should open as any other normal application.
    1. If it doesn’t open as expected or opens WinRAR/WinZIP/7-Zip or any other archiving software, follow here:
      1. Right click the file and point to Open With.
      2. Click on Select Default Program.
      3. Java should be here in the list of programs. If it isn’t then click browse and locate your java installation. It should be in C:Program FilesJavajre7binjava.exe
        1. If you dont have any folder called Java in Program files, then go to www.java.com and download and install it first.
        2. Once Java is installed, follow step 2.
      4. Click OK. Follow step 2.
  3. Click on ‘Add File’ button to add files to it. A dialog box will be presented.
  4. Locate your source code files. You can select more than one file by selecting one file and then holding the ‘Ctrl’ key and selecting other files. Alternatively, if you wish to select all files, you can press ‘Ctrl + A’ to select all files in the directory you are in.
    1. Make sure that you do not select any executable files. This may cause an error.
  5. Click OK/Open.
  6. You should see list of files in the list above ‘Add File’ button. If you wish to add more files, follow step 3.
  7. Once you are done, click Start. It will start counting lines in the files you have selected.
  8. You’re done! The table will display number of code lines in each file and below the table you’ll find total line count and line density.

I hope you like it. Feel free to shout out any suggestions/feedback you have regarding this small application. Have fun!

Did you find this post useful? Spread the word!

  • Facebook
  • Twitter
  • LinkedIn
  • Reddit
  • WhatsApp
  • More
  • Email
  • Skype

Like this:

Like Loading...
Posted in: Skills Tagged: java

If statements in Linux Shell Script

13th February 2012 / Leave a Comment

If statements are important in any programming language. I had a bit of hard time while doing if statements in linux since they are different than those in a conventional programming language. First of all, an if statement to compare whether a value in a variable val1 is equal to 5 is like:
val1=5
if [ $val1 -eq 5 ]
then
     Code here to do some stuff
else
     If above condition is false, then code here gets executed
fi

Note that spaces are important when defining condition. $val1 refers to the variable and -eq simply implies equal to operator to compare if the $val1 is equal to 5.

Seems pretty easy? It is. Other conditional operators are:

Conditional Operator Linux Equivalent
Greater than -gt
Less than -lt
Equal to -eq
Not equal to -ne

Now, if I want to compare strings, for instance, if variable answer is equal to “yes” then the code will be as follows:
if [ "$val" = "yes" ]
then
     Code here to do some stuff
fi

Again, spaces are important here.
In here, ‘=’ can easily be replaced by conventional conditional operators like ‘>’ or ‘<‘ or ‘!=’ etc.

Did you find this post useful? Spread the word!

  • Facebook
  • Twitter
  • LinkedIn
  • Reddit
  • WhatsApp
  • More
  • Email
  • Skype

Like this:

Like Loading...
Posted in: Findings Tagged: linux, shell

Variables in Linux Shell

13th February 2012 / Leave a Comment

Well, this has been a bit tricky for me so I decided to put it on my blog so that it can be helpful to you guys.

First of all, How to define a variable?


count=0

There! I’ve just defined a variable count with 0 as its initial value.
Now, How do you print value of a variable?

echo "$count"

or

echo $count

Next. How do you perform calculations on a variable?
Okay. So assume that you have two variables called val1 and val2 with values 3 and 4 respectively. Now, you want val3 to have the addition of val1 and val2. So,


val1=3
val2=4
val3=expr $val1 + $val2

Similarly, to do subtraction:

val4=expr $val1 - $val2

Note that spaces are very important here.

Now, if you wish to assign value returned by a command to a variable, then it works by doing:

wcount=wc -w myfile.txt

anything between and will be executed as linux command and the value returned by that command will be assigned back to the variable to left.

Did you find this post useful? Spread the word!

  • Facebook
  • Twitter
  • LinkedIn
  • Reddit
  • WhatsApp
  • More
  • Email
  • Skype

Like this:

Like Loading...
Posted in: Findings Tagged: linux, shell

Subscribe to Blog via Email

Join 283 other subscribers.
  • RSS – Posts
  • RSS – Comments

Archives

  • June 2021
  • October 2020
  • September 2020
  • August 2020
  • May 2020
  • August 2018
  • June 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • September 2017
  • August 2017
  • July 2017
  • May 2017
  • April 2017
  • March 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • September 2014
  • December 2013
  • October 2013
  • September 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • January 2013
  • December 2012
  • August 2012
  • April 2012
  • February 2012
  • January 2012

Copyright © 2023 ManthanHD.

Me WordPress Theme by themehall.com

%d bloggers like this: