ENDEDemo vereinbaren
← Zurück zu allen Aufgaben

Ubuntu

Use terminal command to count all the lines of all php files in current directory recursively, show the result on the terminal

Aufgabe und Verlauf liegen im englischen Original vor.

Ergebnis
Gelöst
Punkte
1 / 1
Schritte
4
Dauer
3 min 14 s

Bewertungskriterien

  • Checks that every expected line appears in the output as a line of its own, and that no forbidden line does.
Aufgabendefinition im OSWorld-Repository ansehen

Abschließende Antwort

Done! The terminal shows the result of counting all lines in all .php files under ~/project recursively: - ./views/home.php: 13 lines - ./models/User.php: 21 lines - ./controllers/UserController.php: 12 lines - ./index.php: 8 lines - Total: 54 lines

Verlauf

  1. Schritt 10:01

    The task requires running a terminal command to count all lines of all PHP files recursively in the current directory (~/project) and show the result on a visible terminal. I need to open a terminal window in ~/project first, then run the command. I'll open gnome-terminal in the project directory.

    • Plan erstellt
      1. Open a terminal window in ~/project directory
      2. Run find command to count all lines of all .php files recursively and show result
    • Plan bestätigt2 Teilziele
  2. Schritt 20:10

    I need to open a visible terminal window in ~/project. I'll use the shell tool to launch gnome-terminal with the working directory set to ~/project. Since the shell tool runs in its own background process, launching gnome-terminal from it should create a visible terminal window.

    • Shell-Befehlgnome-terminal --working-directory=/home/user/project
    • Warten
  3. Schritt 30:36

    The terminal is open in ~/project. Now I need to type the find command to count all lines of all .php files recursively. The command `find . -name "*.php" -exec wc -l {} +` will find all .php files and show line counts with a total.

    • Klickthe terminal window showing user@user-virtual-machine:~/project$
    • Eingabefind . -name "*.php" -exec wc -l {} +
    • TastenkombinationReturn
  4. Schritt 41:01

    Both subgoals are achieved: (1) terminal is open in ~/project, (2) the find command ran and shows the total line count (54) for all .php files recursively. I can mark both subgoals as done and finish.

    • Teilziel erreichtGnome terminal opened with working directory ~/project.
    • Teilziel erreichtRan 'find . -name "*.php" -exec wc -l {} +' which showed 54 total lines across 4 .php files.
    • Als abgeschlossen gemeldet