2019年10月29日 星期二

[ Shell ] assign value

Pipeline invokes sub-shell and all changes won't be recorded, a famous bash example:

    cat file | while read line; do var_in_pipe="$line"; done

And var_in_pipe never given values, so use redirect instead.

    while read line; do var_no_pipe="$line"; done < file

2019年10月21日 星期一

[ Patch ] diff and patch

diff -u original modded > mod.patch

-N : absent files as empty.
-a : text mode
-r : directory recursively

patch -p N < mod.patch

-p N : strip N leading components from file names
 N=0 if diff and patch were performed under the same directory

[SSH & SCP] ignore known hosts

Host's key could be changed in many cases. It's a good idea to ignore host's key if no security issues. Add following options ...