Note of The Linux Command Line
心得
在用鼠标点击的图形化桌面之前,单纯用键盘操作软件的时代已经很成熟了。并且还在这样延续下去。鼠标不是电脑操作的唯一模式,至少不是程序员的。
在黑色屏幕下,因为没有鼠标所以只能用按键来操作软件。包括复制、粘贴、光标移动、内容查找和替换等。用键盘操作的高效性在那个时候是没有办法的办法。形成了这种手不离键盘就能操作电脑的习惯之后,即使现在有了鼠标,相比起来鼠标的效率确实要低发发呆
Cutting and Pasting
Shell Script
双引号:双引号的整体是一个字符串,但是字符内容又支持变量($),反引号之间Shell命令和$(...)内的表达式(仅空格脱意,即保留空格);
单引号:单引号的内容是纯字符内容(全部脱意),什么都不要执行;
反引号:反引号的部分为Shell命令;
x='ls *.{txt,log}'
将ls *.{txt,log}的Shell命令执行结果赋给x。
Move the cursor
0 move to then head
O insert a new line before
o insert a new line after
x delete a character
dd delete a line
u undo
Delete and copy
NXX N lines
XW copy word
X0 current to head of current line
X^ current to head of file
X$ current to tail of current line
XG all file
X20G from line 20 to end of file
X={d,y}
d delete
y yank(copy)
Replace
scope s/<pattern>/<replace-to>/g
eg.
%s/ok/g
With g to replace all,or replace the first matched.
2,$s/ok/
Replace scope is from line 2 to the end of file.
Multi file edit
vi foo.txt bar.txt
To open multi file for editing.
:n to move to next opened file
:N to move to previous opened file
:buffers to show all opened files in list(only vim works?)
:buffer N to move to Nth file of buffered file list
Use PS1 to Chang prompt
...
Package management
Installing a Package from a Repository
Debian
apt-get update
apt-get install
package_name
Red Hat
yum install
package_name
Installing a Package from a Package File
Debian
dpkg --install
package_file
Red Hat
rpm -i
package_file