From 09be1759f67db32d762c16a3a7f22328479ef7c5 Mon Sep 17 00:00:00 2001 From: Pezhman-Azizi <80008463+Pezhman-Azizi@users.noreply.github.com> Date: Thu, 18 Sep 2025 15:13:56 +0100 Subject: [PATCH] Finish ls tool exercises --- individual-shell-tools/ls/script-01.sh | 1 + individual-shell-tools/ls/script-02.sh | 1 + individual-shell-tools/ls/script-03.sh | 1 + individual-shell-tools/ls/script-04.sh | 2 ++ 4 files changed, 5 insertions(+) diff --git a/individual-shell-tools/ls/script-01.sh b/individual-shell-tools/ls/script-01.sh index 241b62f5..72f2fb4a 100755 --- a/individual-shell-tools/ls/script-01.sh +++ b/individual-shell-tools/ls/script-01.sh @@ -13,3 +13,4 @@ fi # TODO: Write a command to list the files and folders in this directory. # The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more. +ls diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index d0a5a10f..d3717572 100755 --- a/individual-shell-tools/ls/script-02.sh +++ b/individual-shell-tools/ls/script-02.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command which lists all of the files in the directory named child-directory. # The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt. +ls child-directory diff --git a/individual-shell-tools/ls/script-03.sh b/individual-shell-tools/ls/script-03.sh index 781216d2..8f0627b5 100755 --- a/individual-shell-tools/ls/script-03.sh +++ b/individual-shell-tools/ls/script-03.sh @@ -5,3 +5,4 @@ set -euo pipefail # TODO: Write a command which _recursively_ lists all of the files and folders in this directory _and_ all of the files inside those folders. # The output should be a list of names including: child-directory, script-01.sh, helper-1.txt (and more). # The formatting of the output doesn't matter. +ls -R diff --git a/individual-shell-tools/ls/script-04.sh b/individual-shell-tools/ls/script-04.sh index 72f3817b..ae225dc8 100755 --- a/individual-shell-tools/ls/script-04.sh +++ b/individual-shell-tools/ls/script-04.sh @@ -16,8 +16,10 @@ echo "First exercise (sorted newest to oldest):" # 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. # The output should be a list of names in this order, one per line: helper-3.txt, helper-1.txt, helper-2.txt. +ls -t1 ./child-directory echo "Second exercise (sorted oldest to newest):" # TODO: Write a command which does the same as above, but sorted in the opposite order (oldest first). # The output should be a list of names in this order, one per line: helper-2.txt, helper-1.txt, helper-3.txt. +ls -tr1 child-directory