Skip to content

Commit e81ffbf

Browse files
committed
ls and cat
1 parent fd1db73 commit e81ffbf

8 files changed

Lines changed: 21 additions & 1 deletion

File tree

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

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

55
# TODO: Write a command to output the contents of the helper-1.txt file inside the helper-files directory to the terminal.
66
# The output of this command should be "Once upon a time...".
7+
cd ..
8+
cd helper-files
9+
cat helper-1.txt

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
22

33
set -euo pipefail
4+
cd ..
5+
cd helper-files
6+
cat helper-1.txt helper-2.txt helper-3.txt
47

58
# TODO: Write a command to output the contents of all of the files inside the helper-files directory to the terminal.
69
# Make sure you are only calling `cat` once.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
set -euo pipefail
44

5+
cd ..
6+
cd helper-files
7+
cat -n helper-3.txt
58
# TODO: Write a command to output the contents of the file `helper-3.txt` inside the helper-files directory to the terminal.
69
# This time, we also want to see the line numbers in the output.
710
#

individual-shell-tools/cat/script-04-stretch.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

33
set -euo pipefail
4+
cd ..
5+
cd helper-files
6+
7+
cat helper-1.txt helper-2.txt helper-3.txt | cat -n
48

59
# NOTE: This is a stretch exercise - it is optional.
610

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ fi
1313

1414
# TODO: Write a command to list the files and folders in this directory.
1515
# The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more.
16+
17+
ls

individual-shell-tools/ls/script-02.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 which lists all of the files in the directory named child-directory.
66
# The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt.
7+
ls child-directory
8+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ set -euo pipefail
55
# TODO: Write a command which _recursively_ lists all of the files and folders in this directory _and_ all of the files inside those folders.
66
# The output should be a list of names including: child-directory, script-01.sh, helper-1.txt (and more).
77
# The formatting of the output doesn't matter.
8+
ls -R

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ echo "First exercise (sorted newest to oldest):"
1515

1616
# TODO: Write a command which lists the files in the child-directory directory, one per line, sorted so that the most recently modified file is first.
1717
# The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt.
18-
18+
ls -t -1
1919

2020
echo "Second exercise (sorted oldest to newest):"
2121

22+
ls -tr -1
23+
2224
# TODO: Write a command which does the same as above, but sorted in the opposite order (oldest first).
2325
# The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt.

0 commit comments

Comments
 (0)