From 7b806920080b9928c14a389956b80cd324560dcd Mon Sep 17 00:00:00 2001 From: xuchaoyong Date: Tue, 19 May 2015 09:31:56 +0800 Subject: [PATCH 1/2] Create Shell Programming.md --- Shell Programming.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Shell Programming.md diff --git a/Shell Programming.md b/Shell Programming.md new file mode 100644 index 00000000..e78336a0 --- /dev/null +++ b/Shell Programming.md @@ -0,0 +1,13 @@ +##1. replace the specific line +``` +sed '4 s/hello/good/g' file +sed '4a drink tea' file +sed '4d' +sed -n '5,7p' + +``` + +##2. print the specific colume +``` +sed -n '5p' hello | awk 'BEGIN {FS=","} {print $4}' +``` From 8279d2dcae72c0a34d79477a1e79741f4817db4e Mon Sep 17 00:00:00 2001 From: xuchaoyong Date: Thu, 21 May 2015 09:42:19 +0800 Subject: [PATCH 2/2] Update Shell Programming.md --- Shell Programming.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Shell Programming.md b/Shell Programming.md index e78336a0..3c4ee172 100644 --- a/Shell Programming.md +++ b/Shell Programming.md @@ -7,7 +7,10 @@ sed -n '5,7p' ``` -##2. print the specific colume +##2. print the specific colume in three methods ``` sed -n '5p' hello | awk 'BEGIN {FS=","} {print $4}' +head -n 4 hello | tail -n 1 | cut -d " " -f 3 +sed -n 4p hello | cut -d " " -f 3 +#There are two way to get the specific column with cut or awk. Also, head and tail to get the certain line. ```