In this project, i learned about i/o redirections, pips and filters.
- echo
- cat
- head
- tail
- find
- wc
- sort
- uniq
- grep
- tr
- rev
- cut
- passwd (5) (i.e. man 5 passwd)
- What do the commands head, tail, find, wc, sort, uniq, grep, tr do
- How to redirect standard output to a file
- How to get standard input from a file instead of the keyboard
- How to send the output from one program to the input of another program
- How to combine commands and filters with redirections
- What are special characters
- Understand what do the white spaces, single quotes, double quotes, backslash, comment, pipe, command separator, tilde and how and when to use them
- How to display a line of text
- How to concatenate files and print on the standard output
- How to reverse a string
- How to remove sections from each line of files
- What is the /etc/passwd file and what is its format
- What is the /etc/shadow file and what is its format
- Allowed editors: vi, vim, emacs
- All your scripts will be tested on Ubuntu 20.04 LTS
- All your scripts should be exactly two lines long ($ wc -l file should print 2)
- The first line of all your files should be exactly #!/bin/bash
- A README.md file, at the root of the folder of the project, describing what each script is doing
- You are not allowed to use backticks, &&, || or ;
- All your files must be executable
- You are not allowed to use sed or awk
- Read your /etc/passwd and /etc/shadow files.
- Note: You do not have to learn about fmt, pr, du, gzip, tar, lpr, sed and awk yet.
- Hello World : A script that prints
Hello, World
, followed by a new line to the standard output. - Confused smiley : A script that displays a confused smiley:
"(Ôo)'
. - Let's display a file : A script that displays the content of the
/etc/passwd
file. - What about 2? : A scipt that displays content of
/etc/passwd
and/etc/hosts
. - Last lines of a file : A script that displays the last 10 lines of
/etc/passwd
. - I'd prefer the first ones actually : A scipt that displays the first 10 lines of
etc/passwd
. - Line #2 : A script that displays the third line of the file
iacta
.- The file
iacta
will be in the working directory and you are not allowed to usesed
.
- The file
- It is a good file that cuts iron without making a noise : A script that creates a file named exactly
\*\\'"Holberton School"\'\\*$\?\*\*\*\*\*:)
containing the textHolberton School
ending by a new line.- For this challenge, remember to use a single backslash
\
to escape special characters and double backslash\\
to escape the backslash itself.
- For this challenge, remember to use a single backslash
- Save current state of directory : A script that writes into the file
ls_cwd_content
the result of the commandls -la
. If the filels_cwd_content
already exists, it should be overwritten. If the filels_cwd_content
does not exist, create it. - Duplicate last line : A script that duplicates the last line of the file
iacta
. - No more javascript : A script that deletes all the regular files (not the directories) with a
.js
extension that are present in the current directory and all its subfolders. - Don't just count your directories, make your directories count : A script that counts the number of directories and sub-directories in the current directory.
- The current and present directories should not be taken into account.
- Hidden directories should be counted.
- Solution:
mindepth 1
; To exclude root directory - Others:
maxdepth 1
; To avoid parsing sub directories. (you may need this in future.)
- Solution:
- Whats12's new : A script that prints the 10 newest files in the current directory.
- The output should be; one file per line and sorted from the newest to the oldest.
- Being unique is better than being perfect : A script that takes a list of words as input and prints only words that appear exactly once.
- Input and Output format is;
One word per line
. - Words should be sorted. (use this list as your input to see if the challenge will work. 😊)
cat list | ./13-unique
- Input and Output format is;
- It must be in that file : A script that prints lines containing the pattern
"root"
from the file/etc/passwd
. - Count that word : A script that displays the number of lines that contain the pattern
"bin"
in the file/etc/passwd
. - What's next? : A script that containing the pattern
"root"
and 3 lines after them in the file/etc/passwd
.B
: This shows the lines before your pattern match.A
: This shows the lines after your pattern match.
- I hate bins : A script that displays all the lines in the file
/etc/passwd
that do not contain the pattern"bin"
. - Letters only please : A script that displays all lines of the file
/ect/ssh/sshd_config
starting with a letter, including capital letters as well.- This also works :
grep ^[[:alpha:]] /etc/ssh/sshd_config
- This also works :
- A to Z : A script that replaces all characters
A
andC
from input toZ
andE
respectively. - Without C, you would live in hiago : A script that removes all letters
c
andC
from input. - esreveR : A script that reverse its input.
- DJ Cut Killer : A scipt that displays all users and their home directories, sorted by users, based on the
/etc/passwd
file. - Empty casks make the most noise : A script that finds all empty files and directories in the current directory and all sub-directories.
- Only names of the files and directories should be displayed (not the entire path.)
- Hidden files should be listed also, one file name per line and the listing should end with a new line.
- You are not allowed to use
basename
,grep
,egrep
,fgrep
orrgrep
.
- A gif is worth ten thousand words : A script that lists all the files with a
.gif
extension in the current directory and all its sub-directories.- Hidden files should be listed.
- Only regular files (not directories) should be listed.
- The names of the files should be displayed without their extensions.
- The files should be sorted by byte values, but case-insensitive (file
aaa
should be listed before filebbb
, file.b
should be listed before filea
, and fileRona
should be listed after filejay
) - One file name per line.
- The listing should end with a new line.
- You are not allowed to use
basename
,grep
,egrep
,fgrep
orrgrep
.
- Acrostic : A script that decodes acrostics that use the first letter of each line.
- What to decode:
An acrostic is a poem (or other form of writing) in which the first letter (or syllable, or word) of each line (or paragraph, or other recurring feature in the text) spells out a word, message or the alphabet. The word comes from the French acrostiche from post-classical Latin acrostichis). As a form of constrained writing, an acrostic can be used as a mnemonic device to aid memory retrieval.
Read more here - The ‘decoded’ message has to end with a new line.
- You are not allowed to use
grep
,egrep
,fgrep
orrgrep
.
- What to decode:
- The biggest fan : A script that parses web servers logs in TSV format as input and displays the 11 hosts or IP addresses which did the most requests.
- Download this file:
wget http://indeedeng.github.io/imhotep/files/nasa_19950801.tsv
- Run command this way:
./103-the_biggest_fan < nasa_19950801.tsv
. - Order by number of requests, most active host or IP at the top.
- You are not allowed to use
grep
,egrep
,fgrep
orrgrep
.
- Download this file: