Skip to content

Commit 43a9ffc

Browse files
committed
Answers added for challenges called 'Tail of a Text File #2', ''Tr' Command #1', ''Tr' Command #2' and ''Tr' Command #3'.
1 parent f08da71 commit 43a9ffc

9 files changed

+57
-5
lines changed

linux-shell/00020_HackerrankLinuxShell.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
# Head of a Text File #1
44
# https://www.hackerrank.com/challenges/text-processing-head-1/problem?isFullScreen=true
55

6-
head -n20
6+
while read -r line;
7+
do
8+
echo "$line" | head -n20
9+
done

linux-shell/00021_HackerrankLinuxShell.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
# Head of a Text File #2
44
# https://www.hackerrank.com/challenges/text-processing-head-2/problem?isFullScreen=true
55

6-
head -c20
6+
while read -r line;
7+
do
8+
echo "$line" | head -c20
9+
done

linux-shell/00022_HackerrankLinuxShell.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
# Middle of a Text File
44
# https://www.hackerrank.com/challenges/text-processing-in-linux---the-middle-of-a-text-file/problem?isFullScreen=true
55

6-
head -22 | tail -11
6+
while read -r line;
7+
do
8+
echo "$line" | head -22 | tail -11
9+
done

linux-shell/00023_HackerrankLinuxShell.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
# Tail of a Text File #1
44
# https://www.hackerrank.com/challenges/text-processing-tail-1/problem?isFullScreen=true
55

6-
tail -20
6+
while read -r line;
7+
do
8+
echo "$line" | tail -20
9+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# Tail of a Text File #2
4+
# https://www.hackerrank.com/challenges/text-processing-tail-2/problem?isFullScreen=true
5+
6+
while read -r line;
7+
do
8+
echo "$line" | tail -c20
9+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# 'Tr' Command #1
4+
# https://www.hackerrank.com/challenges/text-processing-tr-1/problem?isFullScreen=true
5+
6+
while read -r line;
7+
do
8+
echo "$line" | tr "(" "[" | tr ")" "]"
9+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# 'Tr' Command #2
4+
# https://www.hackerrank.com/challenges/text-processing-tr-2/problem?isFullScreen=true
5+
6+
while read -r line;
7+
do
8+
echo "$line" | tr -d "[a-z]"
9+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# 'Tr' Command #3
4+
# https://www.hackerrank.com/challenges/text-processing-tr-3/problem?isFullScreen=true
5+
6+
while read -r line;
7+
do
8+
echo "$line" | tr -s ' '
9+
done

linux-shell/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@
2222
| 020 | [Head of a Text File #1](https://www.hackerrank.com/challenges/text-processing-head-1/problem?isFullScreen=true) | [00020_HackerrankLinuxShell](./00020_HackerrankLinuxShell.sh) |
2323
| 021 | [Head of a Text File #2](https://www.hackerrank.com/challenges/text-processing-head-2/problem?isFullScreen=true) | [00021_HackerrankLinuxShell](./00021_HackerrankLinuxShell.sh) |
2424
| 022 | [Middle of a Text File](https://www.hackerrank.com/challenges/text-processing-in-linux---the-middle-of-a-text-file/problem?isFullScreen=true) | [00022_HackerrankLinuxShell](./00022_HackerrankLinuxShell.sh) |
25-
| 023 | [Tail of a Text File #1](https://www.hackerrank.com/challenges/text-processing-tail-1/problem?isFullScreen=true) | [00023_HackerrankLinuxShell](./00023_HackerrankLinuxShell.sh) |
25+
| 023 | [Tail of a Text File #1](https://www.hackerrank.com/challenges/text-processing-tail-1/problem?isFullScreen=true) | [00023_HackerrankLinuxShell](./00023_HackerrankLinuxShell.sh) |
26+
| 024 | [Tail of a Text File #2](https://www.hackerrank.com/challenges/text-processing-tail-2/problem?isFullScreen=true) | [00024_HackerrankLinuxShell](./00024_HackerrankLinuxShell.sh) |
27+
| 025 | ['Tr' Command #1](https://www.hackerrank.com/challenges/text-processing-tr-1/problem?isFullScreen=true) | [00025_HackerrankLinuxShell](./00025_HackerrankLinuxShell.sh) |
28+
| 026 | ['Tr' Command #2](https://www.hackerrank.com/challenges/text-processing-tr-2/problem?isFullScreen=true) | [00026_HackerrankLinuxShell](./00026_HackerrankLinuxShell.sh) |
29+
| 026 | ['Tr' Command #3](https://www.hackerrank.com/challenges/text-processing-tr-3/problem?isFullScreen=true) | [00027_HackerrankLinuxShell](./00027_HackerrankLinuxShell.sh) |

0 commit comments

Comments
 (0)