AWK SED Shell scripts and one liners commands examples

Handy AWK and SED ..frequently used one liners.

In this post I want to continuously update the most frequent and good awk and sed one liners we will use along with samples and examples in simple shell scripts.
1.To count the number of words in a string which are separated with special charters like ,
 # echo  "apple,mango,orange,goa" | awk -F, '{print NF}'
2.How to create and print the continuous variables in a loop after assigning the values to them
echo $temp
while [ $i -le 4 ]
let i="i+1"
eval DYNVAR${i}=$temp$i
eval echo "Value in DYNVAR$i is \$DYNVAR$i "
done the nslookup <IP> output print only Valid hostname of that IP
nc041031:~ # nslookup | awk '/=/ {print $4}' nslookup <Hostname> print only the valid IP of the corresponding host
nc041031:~ # nslookup |  awk '/Address:/ {print $2}' | grep -v "#"
5.Cont ...

Technorati Tags: , , ,

Read more

ORA-01078 LRM-00109: could not open parameter file init.ora /oracle/product/

$ sqlplus "/ as sysdba"
SQL*Plus: Release - Production on Fri Jan 8 00:41:36 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/home/oracle/oracle/product/10.2.0/db_1/dbs/initdb_2orcl.ora'

If you are facing the above error while startup of oracle , possible reasons might be the init{ORA_SID}.ora file not accessible by oracle user which may be due to the init{ORA_SID}.ora file is not located in the default locations or it is not having the proper file permissions to read by oracle user.
In the abobe error messages the ORACLE_SID is db_2orcl, so the name of the init{ORA_SID}.ora file has become initdb_2orcl.ora. So the file might not be available in the default location.
Possible locations to locate init.ora file are as follows
$ORACLE_BASE/admin/$ORACLE_SID/pfile folder
[ or ]
$ORACLE_HOME/dbs folder

Check the name and location of the init-ora file. Then when starting the database specify explicity the location of the initialization file, i.e.

Startup pfile='<full-pathname-of-initialisation-file>'
Example :
SQL> startup pfile='/home/oracle/oracle/product/10.2.0/db_1/admin/db_2orcl/pfile/init.ora.8220089359'
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1218292 bytes
Variable Size              62916876 bytes
Database Buffers           96468992 bytes
Redo Buffers                7168000 bytes
Database mounted.
Database opened.
SQL> select count(*) from tab;


SQL> quit

Reference : [1][2][3]
Oracle Basic FAQs
Technorati Tags: ,

Read more

Interface Vs Abstract class Java

Interface :
Interface is a group of related methods with empty bodies(Signatures). It is not a class. One class may implements multiple interfaces thus helps to achieve multiple inheritance. All the methods in interface are by default abstract with out any abstract key word.
Examples for interface :
interface vehicle {
void startVehicle(Sting commandToStart);
void stopVehicle(String commandToStop);
void speedUp(int speed);
to implement the above interface we can have mutiple classes like Bycycle, MotorBike, Car etc.
class MotorB{

Abstract Class :
A class declared as abstract - It may or may not contain abstract methods. It can't  be instantiated but can be subclassed. Means an abstract class can only be subclassed which mean it can be inherited from. In simple words other classes can inherit an abstract class but they can't initiate the abstract class. One class can extend only one abstract class.
Abstract method :

An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this:Abstract classes are classes that contain one or more abstract methods.

public abstract class vehicle{

//Non abstract method
void int speedUp(int speed){

spedd = speed + 10 ;


abstract void stopVehicle(String commandToStop);


public class thunderBird extends vehicle{

void stopVehicle(String commandToStop)




So in the above abstract class vehicle there are two methods one is speedUp which is non-abstract method and one abstract method stopVehicle . So the classes that extend this abstract class must define the abstract methods declared in abstract class other wise the class itself must declared as abstract class again.

An abstract method is a method that is declared, but contains no implementation.
Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.
An Abstract class without any implementation just looks like an Interface.

Abstract class can implement interface ..

abstract class jumbo implements vehicle {
  void startVehicle(Sting commandToStart){

start ;

void stopVehicle(String commandToStop){

stop ;

void speedUp(int speed){

speed = speed + 20;


Refer some more pages on the same topic here [1][2][3][4]

Technorati Tags:

Read more

Popular Posts

Enter your email address:

Buffs ...


Powered by WidgetsForFree