Remove text between two patterns

This can be done in UNIX by using SED For example: I want to remove the text between foo and bar

 

file.txt contains:

white

green

blue

foo

red

black

bar

yellow


sed '/foo/,/bar/{d;}' file.txt


Output:

white

green

blue

red

black

yellow

Hope this helps!!!
Read more ...

Find and Replace from Command Line

I had a situation where I had to find and replace in files with out creating new files and renaming them back, so after some research on Google I came up with this:


find . type –f | xargs perl –pi –e 's/foo/bar/g'

Read more ...

Find text in files using find

How to list all files having particular text in UNIX, you can do it by using find and grep
For example, if we want to list all files in present working directory containing foo, the following command helps

find . -type f | xargs grep foo

Instead of period you can give the directory location.

find /usr/home/akt -type f | xargs grep -i foo
-i for ignore case
Read more ...

Number of AMP's in Teradata

How to get no. of AMP's in Teradata? It's smple, just run the below query:



SELECT HASHAMP ( );


As AMP's start from 0, you have to add 1

SELECT HASHAMP ( ) + 1;

Read more ...

How to Connect MacBook Pro to Sony Bravia TV

I have recently bought Sony Bravia KDL-40EX500, and my challenge was to connect my MacBook Pro and use it as an external monitor. Is it easy? Yep, all you need is:

- Mini DVI to HDMI adapter (I bought this on monoprice.com)
- HDMI cable
- 3.5 mm stero cable male to male

Now, look for PC/HDMI slot which is behind the LCD TV and audio in which is just above the HDMI slot, see picture (Click to enlarge)

Plugin the cables, and get your MacBook Pro and connect the cables, see pictures:


Now for the TV to work as external monitor, you have to make some changes in the settings, by default when you connect the TV it is considered as second monitor by MacBook Pro. So go to System Preferences > Click on Display and select mirror option, by doing this the display on your MacBook Pro and Sony TV will be same. Now if you close the lid of MacBook Pro, it will go to sleep, to avoid this you have to connect a mouse, key board and plug-in the power adapter. Close the lid and click any key on the keyboard or click the mouse, that's it you are done. Now you can enjoy watching movies from your MacBook Pro on Sony Bravia. Hope you liked the post.
Read more ...

How to Concatnate using AWK in UNIX

I was working on a editing a file using AWK, and I want to concat a string to the output in each line, so I came up with this


filename.out contains:
abc def ;
ghi jkl ;
asd fgh ;


awk '{print $2 "="}' < filename.out

Output:
def=
jkl=
fgh=


Don't forget to use the space.
Read more ...

Spaces

Space Terminology

  Perm Spool Temp
Max The maximum number of bytes available for table, index and permanent journal storage in a database or user A value used to limit the number of bytes the system will consume to create spool files for a user A value used to limit the number of bytes the system will use to store data for global temporary tables for a user
Current The total number of bytes in use to store the tables, subtables, and permanent journals contained in the database or user The number of bytes currently in use for running transactions The number of bytes in use for global temporary tables
Peak The largest number of bytes actually used to store data in this user since the value was last reset The maximum number of bytes used by a transaction run for this user since the value was last reset The maximum number of bytes used by global temporary tables for a user since the value was last reset

Space Limits:

  • Perm and spool space limits are assigned at the database or user level and not at table level
  • When creating users or databases, perm space limits are deducted from the available space of the immediate owner
  • The spool and temp space limits should not exceed that of the immediate owner at the time of you create the object
  • If you do not specify the spool or temp limit, the new object inherits the limit from its immediate owner

Example of space terminology:

Lets say we have a user HR with MaxPerm space 25 MB, MaxSpool space 50 MB and MaxTemp space 30 MB. Now HR creates two users HR01 and HR02 with 6 MB, 4 MB MaxPerm space respectively and assigning 35 MB MaxSpool space to HR01, as there is spool assigned to HR02, it spool space defaults to its immediate parent MaxSpool space i.e. 50 MB. Now HR is left with 15 MB of MaxPerm space. Later HR drops HR01, HR MaxPerm space increases to 21 MB, since it regains Perm space fro HR01. As there is no MaxTemp space assigned to HR01 and HR02 it is defaulted to their immediate parent to 30 MB.

td

Giving one user to another:

  • When you give one object to another object in the hierarchy, all the space allocated to the object goes with it. If you drop the object the space goes to the immediate owner
  • When you give database or user, all descendants (child) of the given object remain descendants (child) of the given object
  • When you give an object to a new parent, the ownership of space is transferred  and limits remain the same
Read more ...