shell
Qinchaowhut
CS
展开
-
diff&&patch
1, diff -u用于一体化输出:ubuntu@VM-62-13-ubuntu:~$ diff -u v1 v2--- v1 2015-06-27 20:43:50.530653196 +0800+++ v2 2015-06-27 20:43:53.530653196 +0800@@ -1,7 +1,7 @@ 4 3 2-5+4 7 7-8+ubuntu@VM-原创 2015-06-27 20:44:40 · 708 阅读 · 0 评论 -
tar&&gzip&&zip
//参考《 Linux Shell 脚本攻略 第二版》tar命令中的-c 代表“create file”tar命令中的-f 代表“specify filename”。(文件名必须紧跟在-f之后,而且-f应该是选项中的最后一个)1,用tar对文件进行归档:ubuntu@VM-62-13-ubuntu:~$ tar -cf all.tar all all~ubuntu@VM原创 2015-06-29 21:03:47 · 674 阅读 · 0 评论 -
head&&tail
//参考《Linux shell脚本攻略 第2版》1,heada)打印前10行:ubuntu@VM-62-13-ubuntu:~$ head fileb)打印前5行:ubuntu@VM-62-13-ubuntu:~$ head-n 5 file 或者ubuntu@VM-62-13-ubuntu:~$ head-5 file c)打印除了最后M行之外的所有原创 2015-06-27 14:24:20 · 821 阅读 · 0 评论 -
Valid Phone Numbers
https://leetcode.com/problems/valid-phone-numbers/# Read from the file file.txt and output all valid phone numbers to stdout.awk '/^([0-9]{3}-|\([0-9]{3}\) )[0-9]{3}-[0-9]{4}$/{print $0}' fi原创 2015-07-11 13:26:01 · 807 阅读 · 0 评论 -
Word Frequency
https://leetcode.com/problems/word-frequency/# Read from the file words.txt and output the word frequency list to stdout.awk '{for(i=1;i<=NF;i++){arr[$i]++}} END{for(w in arr){print w" "arr[w]}}原创 2015-07-11 12:59:37 · 457 阅读 · 0 评论 -
git总结
1,初次运行 Git 前的配置Git 提供了一个叫做 git config 的工具,专门用来配置或读取相应的工作环境变量。而正是由这些环境变量,决定了 Git 在各个环节的具体工作方式和行为。这些变量可以存放在以下三个不同的地方:• /etc/gitconfig 文件:系统中对所有用户都普遍适用的配置。若使用 git config 时用 --system 选项,读写的就是这个文件。原创 2015-07-16 09:39:37 · 379 阅读 · 0 评论 -
Makefile总结
sf:=$(wildcard ./src/*.cpp)of:=$(patsubst %.cpp,%.o,$(sf))sfx:=$(wildcard ./src/rand-utils/*.cpp)ofx=$(patsubst %.cpp,%.o,$(sfx))of+=$(ofx)./bin/grw:$(of) g++ -o $@ $^ $(of):%.o:%.cpp g++ -c $原创 2015-07-15 10:19:50 · 384 阅读 · 0 评论 -
scp.exp脚本:scp命令自动输入密码
#### 1.scp.exp用法(以ubuntu为例):- sudo apt-get install expect- expect scp.exp 127.0.0.1 root passwd srcfile destfile 300#### 2.scp.exp脚本内容```bash#!/usr/bin/expect原创 2018-01-20 18:28:40 · 1913 阅读 · 0 评论