Skip to content

Commit 75f22a6

Browse files
committed
sed commands done
1 parent 7cc05de commit 75f22a6

File tree

6 files changed

+12
-0
lines changed

6 files changed

+12
-0
lines changed

individual-shell-tools/sed/script-01.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ set -euo pipefail
55
# TODO: Write a command to output input.txt with all occurrences of the letter `i` replaced with `I`.
66
# The output should contain 11 lines.
77
# The first line of the output should be: "ThIs Is a sample fIle for experImentIng with sed.".
8+
9+
sed 's/i/I/g' input.txt

individual-shell-tools/sed/script-02.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ set -euo pipefail
55
# TODO: Write a command to output input.txt with numbers removed.
66
# The output should contain 11 lines.
77
# Line 6 of the output should be " Alisha".
8+
9+
sed 's/[0-9]//g' input.txt

individual-shell-tools/sed/script-03.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ set -euo pipefail
44

55
# TODO: Write a command to output input.txt removing any line which contains a number.
66
# The output should contain 6 lines.
7+
8+
sed '/[0-9]/d' input.txt

individual-shell-tools/sed/script-04.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ set -euo pipefail
44

55
# TODO: Write a command to output input.txt replacing every occurrence of the string "We'll" with "We will".
66
# The output should contain 11 lines.
7+
8+
sed "s/We'll/We will/g" input.txt

individual-shell-tools/sed/script-05.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ set -euo pipefail
66
# If a line starts with a number and a space, make the line instead end with a space and the number.
77
# So line 6 which currently reads "37 Alisha" should instead read "Alisha 37".
88
# The output should contain 11 lines.
9+
10+
sed -r 's/^([0-9]+) (.+)/\2 \1/' input.txt

individual-shell-tools/sed/script-06.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ set -euo pipefail
88
# The output should contain 11 lines.
99
# Line 3 should be "It contains many lines, and there are some things you may want to do with each of them.".
1010
# Line 11 should be "We also should remember, when we go shopping, to get 4 items: oranges, cheese, bread, olives.".
11+
12+
sed -r 's/,[^ ]/, /g' input.txt

0 commit comments

Comments
 (0)