add study note file
[dotfiles.git] / study-note.org
1 #+TITLE: Study Note
2 #+AUTHOR: Peng Li
3 #+EMAIL: seudut@gmail.com
4 #+DATE: 2016-08-18
5
6 * Programming Languages
7 ** gnuplog
8
9 1. normal
10 #+BEGIN_SRC gnuplot :exports code :file ./temp/sin.png
11   reset
12   plot sin(x)/x
13 #+END_SRC
14
15 #+RESULTS:
16 [[file:./temp/sin.png]]
17
18 2. plot with data file
19 #+BEGIN_SRC 
20
21 #+END_SRC
22
23
24 * Perl One Line Command
25 #+BEGIN_SRC sh :exports both :results output replace
26   perl --help
27 #+END_SRC
28
29 #+RESULTS:
30 #+begin_example
31
32 Usage: perl [switches] [--] [programfile] [arguments]
33   -0[octal]         specify record separator (\0, if no argument)
34   -a                autosplit mode with -n or -p (splits $_ into @F)
35   -C[number/list]   enables the listed Unicode features
36   -c                check syntax only (runs BEGIN and CHECK blocks)
37   -d[:debugger]     run program under debugger
38   -D[number/list]   set debugging flags (argument is a bit mask or alphabets)
39   -e program        one line of program (several -e's allowed, omit programfile)
40   -E program        like -e, but enables all optional features
41   -f                don't do $sitelib/sitecustomize.pl at startup
42   -F/pattern/       split() pattern for -a switch (//'s are optional)
43   -i[extension]     edit <> files in place (makes backup if extension supplied)
44   -Idirectory       specify @INC/#include directory (several -I's allowed)
45   -l[octal]         enable line ending processing, specifies line terminator
46   -[mM][-]module    execute "use/no module..." before executing program
47   -n                assume "while (<>) { ... }" loop around program
48   -p                assume loop like -n but print line also, like sed
49   -s                enable rudimentary parsing for switches after programfile
50   -S                look for programfile using PATH environment variable
51   -t                enable tainting warnings
52   -T                enable tainting checks
53   -u                dump core after parsing program
54   -U                allow unsafe operations
55   -v                print version, patchlevel and license
56   -V[:variable]     print configuration summary (or a single Config.pm variable)
57   -w                enable many useful warnings
58   -W                enable all warnings
59   -x[directory]     ignore text before #!perl line (optionally cd to directory)
60   -X                disable all warnings
61   
62 Run 'perldoc perl' for more help with Perl.
63
64 #+end_example
65
66 1. Used as =grep=
67 #+BEGIN_SRC sh
68   perl -ne 'print if /expression/' xxx.log;
69 #+END_SRC
70
71 Or 
72 #+BEGIN_SRC sh
73   perl -wnl -e '/keyword/ and print;' xxx.log
74 #+END_SRC
75
76
77 2. Used as =awk=
78 #+BEGIN_SRC sh
79   perl -ne 'print "$1\n" if /aaa=(\d+)\s.*/' xxx.log;
80 #+END_SRC
81
82 3.
83 #+BEGIN_SRC sh
84   perl -pe 'some code' < input.txt > output.txt
85 #+END_SRC
86