menu
What is the Difference Between Using source and sh

date_range Nov. 12, 2019 - Tuesday

Short Answer:

When you call source (or its alias .), you insert the script in the current bash process. So you could read variables set by the script.

When you call sh, you initiate a fork (sub-process) that runs a new session of /bin/sh, which is usually a symbolic link to bash. In this case, environment variables set by the sub-script would be dropped when the sub-script finishes.

Caution: sh could be a symlink to another shell.

How to Customize Bash Colors and Content

date_range Oct. 31, 2019 - Thursday

How to Customize Bash Colors and Content in Linux Terminal Prompt

» How to Customize Bash Colors and Content in Linux Terminal Prompt

linux-system-administration

date_range Oct. 26, 2019 - Saturday

Haven’t posted anything for a long time. Let the notes go on.

In this post, I’d collect all (if possible) necessary knowledge and information about linux account and permission administration.

Create a (Python) Script with a Head Including Information

date_range Mar. 13, 2019 - Wednesday

Problem:

Every time when you create a new script, you alway need to add some information about the script, like create time, author, description, etc. But if you type in by hand every time, it’s time consuming, and also it’s hard to make a uniformed format.

Solution:

  • Write a simple Bash script to auto-generate a new (Python) script is good way to solve the problem above.

The script - kftouchpy:

FILE=$1
echo "\"\"\"
Filename: $FILE
Created on `date`

@author: Kefeng Zhu (john@doe.com)
Description:

\"\"\"
" > $FILE

Usage:

Simply run sh kftouchpy newfile.py, then open the newly created file newfile.py, we have:

"""
Filename: newfile.py
Created on Wed Mar 13 10:37:16 CST 2019

@author: Kefeng Zhu (john@doe.com)

Description:

"""

Make it More Convenient:

Puth the bash script in a directory that is included in your $PATH, and also remember to make it execuable. In this way, you can directly type kftouchpy newfile. Jobs Done!



shravan

[Python/NumPy] Matrix(Arrays) Manipulations & Operations

date_range Feb. 28, 2019 - Thursday

A collection of frequently used python/numpy techniques on matrix (numpy arrays) manipulation and operations.