POP Keywords: apache oracle sybase ...

unix – list content of tar file and extract specific file

To list content of tar.gz file: tar -tvf my-data.tar.gz ‘<looked-for-file-or-path-name>’ To extract specific cotnent from tar.gz file: tar -xvpBf my-data.tar.gz ‘<path-name>’ sources https://www.cyberciti.biz/faq/list-the-contents-of-a-tar-or-targz-file/

creating a python virtual environment

When starting a new python project, it is usually sound practice to use a dedicated virtual environment. By doing so your project is isolated from other applications using python and all dependencies can be properly tracked. ensure python is installed ensure pip is installed (note: starting python3.4, pip is installed by default) ensure virtualenv is installed (note: starting python3.3, venv is installed by default) In a nutshell, if you have python >= python3.4, nothing to install!! Easy 🙂 Run below commands: cd <path/to/my/project> python3 -m venv ./virtualenv Done. Run source ./virtualenv/bin/activate to activate your virtual environment sources https://docs.python.org/3/library/venv.html#module-venv

Feed unix pipe into ls / feed ls with pipe

To feed “ls” instruction with pipe, simply use xargs as per below: find . -type f -name mypattern* | xargs ls -l sources http://stackoverflow.com/questions/18210956/unix-pipe-into-ls

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