Cheatography
https://cheatography.com
also
http://www.cheatography.com/davechild/cheat-sheets/linux-command-line/ good
This is a draft cheat sheet. It is a work in progress and is not finished yet.
sql_load_from_oracle.tmpl
set colsep ,;
set feed off;
set trimspool on;
set linesize 32767;
set pagesize 0;
set heading off;
set echo off;
set termout off;
spool <TMPL_VAR NAME=CSV_FILE>
<TMPL_VAR NAME=SQL_BODY>
/
SPOOL OFF
exit; |
make_sql_load.pl
#!/usr/bin/perl -w
my $file_name = shift;
use HTML::Template;
my $template_dir = '/home/template/';
my $template_name = 'sql_load_from_oracle.tmpl';
my $filename = $template_dir . $template_name;
# open the html template
my $template = HTML::Template->new( filename => $filename );
my $sql_body = '';
{
open my $fh, '<', "$file_name" or die;
local $/ = undef;
$sql_body = <$fh>;
}
my $csv_file = '';
$csv_file = $file_name . '.csv';
# fill in some parameters
$template->param( SQL_BODY => $sql_body );
$template->param( CSV_FILE => $csv_file );
print $template->output; |
|
|
Zip and Cat
1. unzip many files to one directory echo 'for i in $(ls _xml_20/*.zip);do unzip $i -d sm; done' > unzip.sh; nohup bash unzip.sh &
|
2. cat many files to big one find sm -type f -name "*.xml" -exec cat '{}' + > input.txt
|
3. split zip for several files: zip 21100_1.zip --out 21.zip -s 9m
|
4. cmp2dir perl: use Test::Files;use File::Slurp; $di1='1'; $di2='2'; for $file (read_dir($di2)) {compare_ok( $di1.$file,$di2.$file,$file.'ok')}
|
5. remove html tag: cat test.html | sed 's@<\([<>][<>]\)>\([^<>]\)</\1>@\2@g'
|
6. find scripts modidied last 2 month unix: find . -mtime -60 -type f -name '*.sh' -exec ls -l {} \;
|
|
|
Shell Scripting
Shell Script Files |
contain command sequences |
$cat testlogin |
|
files have been assigned the execute permission (using chmod) |
|
simplify repetitious command sequences |
|
the shell runs each command as if it has been typed at the terminal |
|