POP Keywords: apache oracle sybase ...

unix – split large text file into smaller one

run: split -a 5 -d -l 10000 my_file.txt my_file_ usage: split -a 5 -d -l <nb_lines_per_file> <file_to_split> <split_prefix> d = numeric numbering (instead of alphabetical) l = number of lines per split files a = number of characters used for numbering (increase it in case of exhaustion) sources https://kb.iu.edu/d/afar

oracle – apply query to multiple tables

Let’s say you want to grant rights on a set of tables to a given user, here is how to do it: begin for c in ( select ‘grant select on ‘||owner||’.’||table_name||’ to newuser’ cmd from all_tables where owner = ‘myowner’ and table_name like ‘TABLE_NAME_%’ ) loop execute immediate c.cmd; end loop; end; / Note: same logic can be extended to apply any type of query to multiple tables

unix – compare folder tree and identify files which are different

Very easy: sources diff -arq folder1 folder2 http://stackoverflow.com/questions/1644593/unix-compare-two-folders-which-has-many-files-inside-contents

unix – use ps and grep to kill processes [solved]

To kill specific processes in one go, use below syntax: kill $(ps aux | grep ‘[m]y_specific_process’ | awk ‘{print $2}’) Note: using ‘[]’ is a hack to prevent grep process from being included in returned output sources http://stackoverflow.com/questions/3510673/find-and-kill-a-process-in-one-line-using-bash-and-regex

oracle – how to dump query output into csv file via cli [solved]

A way to do it is to use sqlplus script. create file to execute with below content (vi my_query.sql): SET ECHO OFF; SET LINESIZE 32767; SET TAB OFF; SET NEWPAGE NONE; SET PAGESIZE 32767; SET LONG 100000000; SET HEADING ON; SET WRAP OFF; SET SCAN OFF; SET FEEDBACK OFF; SET SERVEROUTPUT ON; SET HEADSEP OFF; SET PAGESIZE 0; SET TRIMSPOOL ON; SET COLSEP ‘,’; ALTER SESSION SET NLS_DATE_FORMAT=’YYYYMMDD’; SPOOL /path/to/my_query.out <paste_sql_query_here> COMMIT; EXIT; call sqlplus as per below: $ORACLE_HOME/bin/sqlplus -S -l <user/password@server> @<path/to/my_query.sql> That’s it! Ouptut of run should be available under /path/to/my_query.out as specified in SPOOL variable. Tip: run SPOOL OFF; to turn […]

run process in background and keep it running after ssh exit [done]

To do so, simply use “disown <pid>” command. Proceed as follows: ssh into server run command and put it in background: myprocess.sh & note the id of the command being returned (or run either “jobs -l” or “ps aux | grep myprocess” to find it back) run command: disown <pid> exit ssh ssh into server again run “ps aux | grep <pid>” should return content Alternatively use “nohup”: simply prefix your command with “nohup” example: nohup myprocess.sh & sources http://www.cyberciti.biz/faq/unix-linux-disown-command-examples-usage-syntax/ http://stackoverflow.com/questions/5164985/how-can-i-use-nohup-to-run-process-as-a-background-process-in-linux http://unix.stackexchange.com/questions/3886/difference-between-nohup-disown-and http://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session

python – which site-packages folder are used in my environment [solved]

Log into your python environment and run: import site print(‘\n’.join(site.getsitepackages())) print(‘\n’.join(site.getusersitepackages())) sources http://pythonsimple.noucleus.net/python-install/python-site-packages-what-they-are-and-where-to-put-them

python 3.5 – install oracle mysql driver on ubuntu [solved]

Installing this mysql driver is surprisingly quite a painful experience. Steps Download package relevant for your distribution and python version from oracle website: https://dev.mysql.com/downloads/connector/python/ Install downloaded package: sudo dpkg -i mysql-connector-python-py3 _2.1.3-1ubuntu15.04_all.deb Go into python and run “import mysql” For all virtualenvs, simply symlink: ln -s /usr/lib/python3/dist-packages/mysql <path_to_virtual_env>/lib/pythonX.X/site-packages It should be good by now.

python – which site-packages folder are used in my environment [solved]

Log into your python environment and run: import site print(‘\n’.join(site.getsitepackages())) print(‘\n’.join(site.getusersitepackages())) sources http://pythonsimple.noucleus.net/python-install/python-site-packages-what-they-are-and-where-to-put-them

unix – file cannot be deleted or modified, even by root user [solved]

I had a file that could not be edited / removed / moved, even by root user. Reason for it is that this file was declared immutable. To solve this, run: sudo chattr -i <path/to/file> Now file can be edited/removed/moved. sources http://www.omgubuntu.co.uk/2016/03/fix-failed-to-fetch-google-chrome-apt-error-ubuntu