Posts

Remove Control M characters from a file in UNIX

Open file in putty and execute the following command :%s,^VM,,g <------------ to remove ctrl m characters

To find Solaris version

1) cat /etc/*release 2) uname -a

To Verify ML versions

Following commands will give the ML versions in AIX 1) instfix -i | grep ML 2) oslevel -r

Find command in UNIX

Find text in the current folder and redirect output to OP1.txt find . -name "*" -exec grep "FIND THIS TEXT" {} \;>> OP1.txt Find text in the current folder and print the output on screen grep "FIND THIS TEXT" `find .` |cut -d":" -f1 | grep -v properties | sort -u find the text and print the file name along with the path on screen find xxxxxPATH_TO_SEARCHxxxxxx -type f -exec grep -l 'FIND THIS TEXT' {} \;

Update a column of a table with random values

Query to update a column of a table with random values within a range of 1 to 21 UPDATE <%table_name%> SET <%column_name%> = trunc(dbms_random.value(2,21))

Monitor Memory Status (available memory)

copy the following into a .sh file and execute the same from putty #!/usr/bin/ksh #memory calculator um=`svmon -G | head -2|tail -1| awk {'print $3'}` um=`expr $um / 256` tm=`lsattr -El sys0 -a realmem | awk {'print $2'}` tm=`expr $tm / 1000` fm=`expr $tm - $um` echo "\n\n-----------------------"; echo "System : (`hostname`)"; echo "-----------------------\n\n"; echo "\n\n-----------------------"; echo " Users Login information \n"; for ENTRY in `finger | cut -d " " -f1 | grep -v Login | uniq` do echo "`finger -l $ENTRY | head -1 | cut -d \" \" -f14` ---> `finger -l $ENTRY | awk '{ print $2 }' | tail -2 | head -1`"; #finger -l $ENTRY | awk '{ print $2 }' | tail -2 | head -1; done echo "-----------------------\n"; echo "\n----------------------"; echo "Memory Information\n\n"; echo "total memory = $tm MB" echo "free memory = $fm ...

Search for a string in schema

declare cursor c1 is select column_name , table_name from user_tab_columns where data_type = 'VARCHAR2' ; -- and table_name = 'TABLE_NAME' ; vSQL varchar2 ( 32676 ) := null ; vParam varchar2 ( 100 ) := 'STING_YOU_WANT_TO_SEARCH' ; vcnt number ; begin for x in c1 loop begin vSQL := 'select count(*) from ' ||x.table_name|| ' where ' ||x.column_name|| ' like ' ||chr( 39 )|| '%' ||vparam|| '%' ||chr( 39 ); execute immediate vSQL into vcnt; if vcnt > 0 then dbms_output.put_line( 'Found in ' ||x.table_name|| ' ' ||x.column_name); end if ; exception when others then dbms_output.put_line( 'Problem in ' ||vSQL); end ; end loop ; end ;