Skip to content

Latest commit

 

History

History

0x02-shell_redirections

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

0x02. Shell, I/O Redirections and filters - DevOps Project

This project is a part of the DevOps curriculum and aims to enhance your proficiency in working with the shell, specifically Bash, within a Linux environment. Throughout this project, you will engage in tasks that explore various aspects of shell commands, file manipulation, and input/output redirection.

Learning Objectives

By completing this project, you will:

  • Develop a deep understanding of shell commands and their applications.
  • Gain familiarity with essential commands like head, tail, find, wc, sort, uniq, grep, and tr.
  • Learn to redirect standard input/output to and from files.
  • Discover how to chain commands and filters using redirections.
  • Acquire knowledge about special characters and their usage in the shell

Project Structure

The project contains a series of scripts, each addressing specific tasks related to shell redirections. Here's a brief overview of the tasks:

  1. Hello World

    • 0-hello_world: Write a script that prints "Hello, World" followed by a new line to the standard output.
  2. Confused Smiley

  3. Let's Display a File

  4. What About 2?

    • 3-twofiles: Display the content of both /etc/passwd and /etc/hosts files.
  5. Last Lines of a File

    • 4-lastlines: Display the last 10 lines of the /etc/passwd file.
  6. I'd Prefer the First Ones Actually

    • 5-firstlines: Display the first 10 lines of the /etc/passwd file.
  7. Line #2

  8. It is a Good File That Cuts Iron Without Making a Noise

    • 7-file: Create a shell script that creates a file named exactly *\'"Best School"'\*$?*****:) containing the text "Best School" ending with a new line.
  9. Save Current State of Directory

    • 8-cwd_state: Write a script that writes into the file ls_cwd_content the result of the command ls -la. If the file ls_cwd_content already exists, it should be overwritten. If the file ls_cwd_content does not exist, create it.
  10. Duplicate Last Line

  11. No More JavaScript

    • 10-no_more_js: Write a script that deletes all the regular files (not directories) with a .js extension that are present in the current directory and all its subfolders.
  12. Don't Just Count Your Directories, Make Your Directories Count

    • 11-directories: Write a script that counts the number of directories and sub-directories in the current directory. Hidden directories should be counted, and the current and parent directories should not be taken into account.
  13. What’s New

    • 12-newest_files: Create a script that displays the 10 newest files in the current directory, one file per line, sorted from newest to oldest.
  14. Being unique is better than being perfect

    • 13-unique: Create a script that takes a list of words as input and prints only words that appear exactly once.
  15. It must be in that file

    • 14-findthatword: Display lines containing the pattern "root" from the file /etc/passwd.
  16. Count that word

    • 15-countthatword: Display the number of lines that contain the pattern "bin" in the file /etc/passwd.
  17. What's next?

    • 16-whatsnext: Display lines containing the pattern "root" and 3 lines after them in the file /etc/passwd.
  18. I hate bins

    • 17-hidethisword: Display all the lines in the file /etc/passwd that do not contain the pattern "bin".
  19. Letters only please

    • 18-letteronly: Display all lines of the file /etc/ssh/sshd_config starting with a letter, including capital letters.
  20. A to Z

    • 19-AZ: Replace all characters 'A' and 'c' from input to 'Z' and 'e' respectively.
  21. Without C, you would live in hiago

    • 20-hiago: Create a script that removes all letters 'c' and 'C' from input.
  22. esreveR

  23. DJ Cut Killer

    • 22-users_and_homes: Write a script that displays all users and their home directories, sorted by users, based on the /etc/passwd file.
  24. Empty casks make the most noise

    • 100-empty_casks: Write a command that finds all empty files and directories in the current directory and all sub-directories. List only the names of the files and directories (not the entire path).
  25. A gif is worth ten thousand words

    • 101-gifs: Write a script that lists all the files with a .gif extension in the current directory and all its sub-directories. List only regular files (not directories) and sort them by byte values in a case-insensitive manner.
  26. Acrostic

    • 102-acrostic: Create a script that decodes acrostics that use the first letter of each line.
  27. The biggest fan

    • 103-the_biggest_fan: Write a script that parses web server logs in TSV format as input and displays the 11 hosts or IP addresses which did the most requests, ordered by the number of requests (most active host or IP at the top).

Resources

Read or watch:

man or help:

echo cat head tail find wc sort uniq grep tr rev cut passwd (5) (i.e. man 5 passwd)

For detailed instructions and examples, refer to the respective script files in this repository.


Special Thanks for Project Guidance to

  • Julien Barbier

YouTube | Twitter | LinkedIn

License

This project is licensed under the terms of the MIT License.


© 2023 ALX. All rights reserved.