Pages

Wednesday, March 28, 2012

Arithmetic equations in bash

Basic equations in bash scripts:

x=15
y=8
sum=$((x+y))

dif=$((x-y))

mod=$((x%y))

prod=$((x*y))

Tuesday, March 6, 2012

How to search a word in multiple files

1. Search a word in all the files with the .txt extension in current directory.

 grep -H "word" *.txt

2. Search a word in all the files in current directory and its subdirectories. 

grep -H -r "word" home/directory

-H = display the name of the file
-r = search recursively trough subdirectories

Friday, February 24, 2012

How to remove/replace a given character/word from all the filenames in current directory using sed

#!/bin/bash
extension="txt"
for files in *.$extension; 
do 
    mv $files `echo $files | sed 's/B/A/g'`; 
done;
 
The mv command is used to rename the files.

sed parses the filename and replaces all the occurrences of "B" character with "A".

eg. BAOBAB.txt will be replaced by AAOAAA.txt

The script is case sensitive. Also, be careful with special characters that need to be escaped with "\".
For example if you have a file called ^name.txt and want to replace "^" character from the filename with "A", using the command:

mv $files `echo $files | sed 's/^/A/g'`;  

will lead to the following output:

A^name.txt

You need to escape "^" character:


mv $files `echo $files | sed 's/\^/A/g'`;

In this case the output will be:

Aname.txt

This script also works if you use words instead of characters.

Monday, February 13, 2012

Install Xara Xtreme on Ubuntu 10.04

Xara Xtreme is a leading-edge graphic tool, easy-to-use and one of the world's best free graphics program.

Xara Xtreme  is supplied in autopackage format. Follow the next steps to install the program:
  1. Download the Xara Xtreme Linux installation package (http://www.xaraxtreme.org)
  2. Make this package executable:
    • Click on "Properties".
    • Click on the "Permissions" tab.
    • Ensure the checkbox "Allow executing file as program" is checked.
    • Click on "Close".
  3. Double click on .package file
  4. The installer will begin by prompting you whether to download the autopackage code (if autopackage is not already installed). Answer yes (or simply press Enter).
  5. After some time, it will display a window asking for the administrator (sudo) password. This is to install autopackage system-wide.
  6. After autopackage has finished installing, Xara installation will begin. You may be prompted for the password again.
  7. When Xara has finished installing, you should have a Xara icon in your application menu (e.g. Applications > Graphics > Xara Xtreme)

Download autopackage archive from

Saturday, June 5, 2010

How to install applications in Ubuntu?

There are multiple ways to install applications in Linux:
1. From the command line 
Run: sudo apt-get install app_name
If app_name files are ported for the Linux distribution (Ubuntu, Fedora, etc) and are available then it will download and install all the files automatically.

2. Trough a graphical package management tool 
If you are not comfortable using the command line, you can use many graphical front-end tools for Apt.   
Ubuntu
        Add new applications
        Applications menu → Ubuntu Software Center → Get Software
        Remove installed applications
        Applications menu → Ubuntu Software Center → Installed Software
        → Select application → Remove
RedHat  
        Start → System Settings → Add/Remove Applications

3. Autopackage 
Autopackage has been developed keeping in mind the functionality of MS Windows installers, Autopackage is software that lets you create binary packages of software for Linux that will install automatically, interactively on any Linux distribution through multiple front-end. When the Autopackage installer file is run to install a certain software, it checks the system for the installed component the software in question needs, installs it if it finds in its installer files or downloads and installs it from internet (similar as Debian’s Apt) if it does not find it locally. This concept is in infant stage, and you can find a few applications Autopackaged already.
Source: http://raviratlami1.blogspot.com

4. From a source file
The best way to install an application in Linux is to compile its source. Linux sources are available as compressed tar gzipped or bzipped files. To install application through its source, copy or download the source in a directory you think appropriate and then decompress them. For example, if you have source file in tar gzipped format, say, source file of package xyz, xyz-3.29.tar.gz, then the command to unpack it will be:
tar -zxvf xyz-3.29.tar.gz
The command will create a directory containing all the source files called xyz-3.29 in current directory. Now change to this directory and see the directory listing. You will find many files and directories there. You will also find a script file called configure. Now give the following command:
./configure
If you had installed necessary development environment including compilers, make, automake tools in your computer, then it will start compiling necessary information and creating necessary make files. If this command finishes without errors then give next command:
make
This command should also finish without any error massage. Finally, change to root user mode by giving su command if you are not already in super user mode, and then give following command to install executable files at appropriate directories:
make install
Don't forget to give following command to remove unnecessary files created by above commands:
make clean
If you think every thing has gone right, then you can run the application by giving its name as command (in general), here, xyz. In some cases you may find program menu entries automatically added, else you have to add them manually.
Source: http://raviratlami1.blogspot.com

You need administrative access to Add/Remove Programs.

Linux Usefull Applications

Here there are some of the best Linux applications:

 1. Work with files (File Managers)
- NC style: Midnight Commander (mc)
- Windows Commander style: Krusader
- Windows style: Konqueror
- Text editors: Kedit, Gedit
2. Multimedia
- Music/mp3/ogg players: Rhythmbox Music Player, Mplayer, Winamp
- Video / mpeg4 players: Mplayer, Kplayer
- Audio editors: Ardour, Audacity
- Programs for CD/DVD burning with GUI: K3b Support: k3b.org
- Graphic files viewer: Xnview download from: xnview.com, GQView
- Simple graphic editors:  OpenOffice.org Drawing,  Xpaint
- Drawing program for children: Tuxpaint
- Powerful graphic editors in PhotoShop style: Gimp ImageMagick
- Program for work with vector graphics: Inkscape
- 3D-graphics: Maya, Blender
3. Office/business
- Office suite: OpenOffice download from: openoffice.org
- Graphing / charting data: Kivio, Dia
4. Programming and development
- IDE: CodeForge, Eclipse
- C++ IDE: gcc
- Assembler: NASM
- Disassembler: Code source is open, Idasm
- Java IDE: NetBeans, Eclipse
- FTP-server: pure-ftpd, vsftpd, ftp
- Language for Web-development: PHP, Perl, ASP (module for Apache)
- Database engine: MySQL, PostgresSQL, Freebird
5. Scientific and special programs
- Math system in Matlab style: Matlab
- Math system in Mathematica style: Maxima
- Equation/math editor: OpenOffice Math

The applications are free and in order to install them you need to run the following command in the terminal:
sudo apt-get install application name








Friday, June 4, 2010

Tux



        Linus Torvalds personal mascot is a penguin nicknamed Tux, which has been widely adopted by the Linux community as the mascot of the Linux kernel. The first person to call the penguin Tux was James Hughes, who said that it stood for "(T)orvalds (U)ni(X)".

Source: wikipedia.org