Linux Labs

Bash: text processing and scripts / Stage 4 of 9

A script is a file of commands

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 6 · on a machine · 4 min

Your own command

Now all of it together, with no ready-made commands: your own script that runs by name from any directory.

You need a command called reports-count. It prints one number — how many files are in the ~/script-lab/old reports directory. Write the script in nano or vim, and test it from another directory, such as /tmp. The exercise check runs the command in a fresh login to the machine — as if you had just connected.

Exercise · do it

Make your own command

Make a command called reports-count: a script in ~/bin that prints one number — how many files are in the ~/script-lab/old reports directory. It must be found by name from any directory, including after a fresh login.

Sign in and start The machine is available after signing in

Goals · 0 of 3

  • Write the reports-count script in ~/bin with a shebang on the first line not done yet
  • Make the command found by name after a login not done yet
  • Print the number of files in the directory with a space in its name not done yet

Step goals

0 of 3
  • Write the reports-count script in ~/bin with a shebang on the first line — not done yet
  • Make the command found by name after a login — not done yet
  • Print the number of files in the directory with a space in its name — not done yet
Ubuntu 24.04

Step goals

0 of 3
  • Write the reports-count script in ~/bin with a shebang on the first line — not done yet
  • Make the command found by name after a login — not done yet
  • Print the number of files in the directory with a space in its name — not done yet
Loading…