From af05a14046631ad3510d7f14b13d94623d678171 Mon Sep 17 00:00:00 2001 From: rrylee Date: Tue, 22 Jan 2019 08:56:16 +0800 Subject: [PATCH] add --- Linux-Shell/awk-1.sh | 1 + Linux-Shell/awk-2.sh | 1 + Linux-Shell/awk-3.sh | 1 + Linux-Shell/awk-4.sh | 1 + ...orials-concatenate-an-array-with-itself.sh | 6 +++++ ...ount-the-number-of-elements-in-an-array.sh | 2 ++ ...s-display-the-third-element-of-an-array.sh | 2 ++ ...tutorials-filter-an-array-with-patterns.sh | 2 ++ .../bash-tutorials-read-in-an-array.sh | 3 +++ ...-capital-letter-from-each-array-element.sh | 2 ++ Linux-Shell/bash-tutorials-slice-an-array.sh | 2 ++ Linux-Shell/lonely-integer-2.sh | 2 ++ ...-processing-in-linux-the-grep-command-1.sh | 1 + ...-processing-in-linux-the-grep-command-3.sh | 1 + ...-processing-in-linux-the-grep-command-4.sh | 1 + ...-processing-in-linux-the-grep-command-5.sh | 1 + ...t-processing-in-linux-the-sed-command-1.sh | 2 ++ ...t-processing-in-linux-the-sed-command-2.sh | 1 + ...t-processing-in-linux-the-sed-command-3.sh | 1 + Linux-Shell/text.txt | 25 ++++++++----------- 20 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 Linux-Shell/awk-1.sh create mode 100644 Linux-Shell/awk-2.sh create mode 100644 Linux-Shell/awk-3.sh create mode 100644 Linux-Shell/awk-4.sh create mode 100644 Linux-Shell/bash-tutorials-concatenate-an-array-with-itself.sh create mode 100644 Linux-Shell/bash-tutorials-count-the-number-of-elements-in-an-array.sh create mode 100644 Linux-Shell/bash-tutorials-display-the-third-element-of-an-array.sh create mode 100644 Linux-Shell/bash-tutorials-filter-an-array-with-patterns.sh create mode 100644 Linux-Shell/bash-tutorials-read-in-an-array.sh create mode 100644 Linux-Shell/bash-tutorials-remove-the-first-capital-letter-from-each-array-element.sh create mode 100644 Linux-Shell/bash-tutorials-slice-an-array.sh create mode 100644 Linux-Shell/lonely-integer-2.sh create mode 100644 Linux-Shell/text-processing-in-linux-the-grep-command-1.sh create mode 100644 Linux-Shell/text-processing-in-linux-the-grep-command-3.sh create mode 100644 Linux-Shell/text-processing-in-linux-the-grep-command-4.sh create mode 100644 Linux-Shell/text-processing-in-linux-the-grep-command-5.sh create mode 100644 Linux-Shell/text-processing-in-linux-the-sed-command-1.sh create mode 100644 Linux-Shell/text-processing-in-linux-the-sed-command-2.sh create mode 100644 Linux-Shell/text-processing-in-linux-the-sed-command-3.sh diff --git a/Linux-Shell/awk-1.sh b/Linux-Shell/awk-1.sh new file mode 100644 index 0000000..94982bf --- /dev/null +++ b/Linux-Shell/awk-1.sh @@ -0,0 +1 @@ +awk '{if ($4 == "") print "Not all scores are available for", $1 }' \ No newline at end of file diff --git a/Linux-Shell/awk-2.sh b/Linux-Shell/awk-2.sh new file mode 100644 index 0000000..a4442f9 --- /dev/null +++ b/Linux-Shell/awk-2.sh @@ -0,0 +1 @@ +awk '{if ($1 >= 50 && $2 >= 50 && $3 >= 50) print $1, ": Pass"; else print $1, ": Fail";}' \ No newline at end of file diff --git a/Linux-Shell/awk-3.sh b/Linux-Shell/awk-3.sh new file mode 100644 index 0000000..a4442f9 --- /dev/null +++ b/Linux-Shell/awk-3.sh @@ -0,0 +1 @@ +awk '{if ($1 >= 50 && $2 >= 50 && $3 >= 50) print $1, ": Pass"; else print $1, ": Fail";}' \ No newline at end of file diff --git a/Linux-Shell/awk-4.sh b/Linux-Shell/awk-4.sh new file mode 100644 index 0000000..c12d2f3 --- /dev/null +++ b/Linux-Shell/awk-4.sh @@ -0,0 +1 @@ +awk 'ORS=NR%2? ";":"\n"' \ No newline at end of file diff --git a/Linux-Shell/bash-tutorials-concatenate-an-array-with-itself.sh b/Linux-Shell/bash-tutorials-concatenate-an-array-with-itself.sh new file mode 100644 index 0000000..b9cbdd9 --- /dev/null +++ b/Linux-Shell/bash-tutorials-concatenate-an-array-with-itself.sh @@ -0,0 +1,6 @@ +for line in `cat`; do + countries=( "${countries[@]}" $line ) +done + +countries=("${countries[@]}" "${countries[@]}" "${countries[@]}") +echo "${countries[@]}" \ No newline at end of file diff --git a/Linux-Shell/bash-tutorials-count-the-number-of-elements-in-an-array.sh b/Linux-Shell/bash-tutorials-count-the-number-of-elements-in-an-array.sh new file mode 100644 index 0000000..5ca2c22 --- /dev/null +++ b/Linux-Shell/bash-tutorials-count-the-number-of-elements-in-an-array.sh @@ -0,0 +1,2 @@ +arr=($(cat)) +echo ${#arr[@]} \ No newline at end of file diff --git a/Linux-Shell/bash-tutorials-display-the-third-element-of-an-array.sh b/Linux-Shell/bash-tutorials-display-the-third-element-of-an-array.sh new file mode 100644 index 0000000..a45b521 --- /dev/null +++ b/Linux-Shell/bash-tutorials-display-the-third-element-of-an-array.sh @@ -0,0 +1,2 @@ +a=($(cat)) +echo ${a[3]} \ No newline at end of file diff --git a/Linux-Shell/bash-tutorials-filter-an-array-with-patterns.sh b/Linux-Shell/bash-tutorials-filter-an-array-with-patterns.sh new file mode 100644 index 0000000..4711b1c --- /dev/null +++ b/Linux-Shell/bash-tutorials-filter-an-array-with-patterns.sh @@ -0,0 +1,2 @@ +arr=($(cat)) +echo ${arr[@]/*[aA]*/} \ No newline at end of file diff --git a/Linux-Shell/bash-tutorials-read-in-an-array.sh b/Linux-Shell/bash-tutorials-read-in-an-array.sh new file mode 100644 index 0000000..76655b3 --- /dev/null +++ b/Linux-Shell/bash-tutorials-read-in-an-array.sh @@ -0,0 +1,3 @@ +# 1 +paste -sd ' ' + diff --git a/Linux-Shell/bash-tutorials-remove-the-first-capital-letter-from-each-array-element.sh b/Linux-Shell/bash-tutorials-remove-the-first-capital-letter-from-each-array-element.sh new file mode 100644 index 0000000..033b82e --- /dev/null +++ b/Linux-Shell/bash-tutorials-remove-the-first-capital-letter-from-each-array-element.sh @@ -0,0 +1,2 @@ +arr=($(cat)) +echo ${arr[@]/[A-Z]/.} \ No newline at end of file diff --git a/Linux-Shell/bash-tutorials-slice-an-array.sh b/Linux-Shell/bash-tutorials-slice-an-array.sh new file mode 100644 index 0000000..21fa15f --- /dev/null +++ b/Linux-Shell/bash-tutorials-slice-an-array.sh @@ -0,0 +1,2 @@ +arr=($(cat)) +echo ${arr[@]:3:5} \ No newline at end of file diff --git a/Linux-Shell/lonely-integer-2.sh b/Linux-Shell/lonely-integer-2.sh new file mode 100644 index 0000000..3e180ec --- /dev/null +++ b/Linux-Shell/lonely-integer-2.sh @@ -0,0 +1,2 @@ +read +tr ' ' '\n' | sort | uniq -u \ No newline at end of file diff --git a/Linux-Shell/text-processing-in-linux-the-grep-command-1.sh b/Linux-Shell/text-processing-in-linux-the-grep-command-1.sh new file mode 100644 index 0000000..63f87be --- /dev/null +++ b/Linux-Shell/text-processing-in-linux-the-grep-command-1.sh @@ -0,0 +1 @@ +grep -wi 'the' diff --git a/Linux-Shell/text-processing-in-linux-the-grep-command-3.sh b/Linux-Shell/text-processing-in-linux-the-grep-command-3.sh new file mode 100644 index 0000000..87fd0a1 --- /dev/null +++ b/Linux-Shell/text-processing-in-linux-the-grep-command-3.sh @@ -0,0 +1 @@ +grep -viw that \ No newline at end of file diff --git a/Linux-Shell/text-processing-in-linux-the-grep-command-4.sh b/Linux-Shell/text-processing-in-linux-the-grep-command-4.sh new file mode 100644 index 0000000..d3b1743 --- /dev/null +++ b/Linux-Shell/text-processing-in-linux-the-grep-command-4.sh @@ -0,0 +1 @@ +grep -Eiw 'the|that|then|those' \ No newline at end of file diff --git a/Linux-Shell/text-processing-in-linux-the-grep-command-5.sh b/Linux-Shell/text-processing-in-linux-the-grep-command-5.sh new file mode 100644 index 0000000..178fad6 --- /dev/null +++ b/Linux-Shell/text-processing-in-linux-the-grep-command-5.sh @@ -0,0 +1 @@ +grep '\([0-9]\) *\1' \ No newline at end of file diff --git a/Linux-Shell/text-processing-in-linux-the-sed-command-1.sh b/Linux-Shell/text-processing-in-linux-the-sed-command-1.sh new file mode 100644 index 0000000..017c188 --- /dev/null +++ b/Linux-Shell/text-processing-in-linux-the-sed-command-1.sh @@ -0,0 +1,2 @@ +sed -e 's/\/this/' + diff --git a/Linux-Shell/text-processing-in-linux-the-sed-command-2.sh b/Linux-Shell/text-processing-in-linux-the-sed-command-2.sh new file mode 100644 index 0000000..7c814a0 --- /dev/null +++ b/Linux-Shell/text-processing-in-linux-the-sed-command-2.sh @@ -0,0 +1 @@ +sed -E 's/[tT][hH][yY]/your/g' \ No newline at end of file diff --git a/Linux-Shell/text-processing-in-linux-the-sed-command-3.sh b/Linux-Shell/text-processing-in-linux-the-sed-command-3.sh new file mode 100644 index 0000000..9cff5c6 --- /dev/null +++ b/Linux-Shell/text-processing-in-linux-the-sed-command-3.sh @@ -0,0 +1 @@ +sed -E 's/thy/{&}/gi' \ No newline at end of file diff --git a/Linux-Shell/text.txt b/Linux-Shell/text.txt index bf2f49a..f61027c 100644 --- a/Linux-Shell/text.txt +++ b/Linux-Shell/text.txt @@ -1,15 +1,10 @@ -Albany, N.Y. -Albuquerque, N.M. -Anchorage, Alaska -Asheville, N.C. -Atlanta, Ga. -Atlantic City, N.J. -Austin, Texas -Baltimore, Md. -Baton Rouge, La. -Billings, Mont. -Birmingham, Ala. -Bismarck, N.D. -Boise, Idaho -Boston, Mass. -Bridgeport, Conn. +Namibia +Nauru +Nepal +Netherlands +NewZealand +Nicaragua +Niger +Nigeria +NorthKorea +Norway