Imagine following dataset
- Type=Carriage
Id=0
Color=Black
- Type=Carriage
Color=Blue
Id=1
- Id=2
Type=Engine
Color=Black
- Type=Engine
Color=Blue
Id=3
- Type=Carriage
Id=4
Color=Blue
- Type=Engine
Color=Blue
Id=5
Goal: Find out Ids of blue carriages.
Expected output:
Id=1
Id=4
Note for this exercise: assume that email addresses do not contain spaces.
Imagine following dataset:
2025-08-18 12:01 User [email protected] phone=9876543210 action=login
2025-08-18 12:05 User [email protected] phone=1234567890 action=login
2025-08-18 12:07 User [email protected] phone=1112223333 action=reset
2025-08-18 12:08 User [email protected] phone=9999999999 action=login
2025-08-18 12:08 User [email protected] phone=9999999999 action=logout
2025-08-18 12:09 User [email protected] phone=9876543210 action=logout
2025-08-18 12:09 User [email protected] action=hack
2025-08-18 12:09 System pid=1 action=shutdown
Goal: Find email addresses where multiple phone numbers are associated with same email address.
Expected output:
[email protected]
Goal: Convert all words to lowercase in the following, remove the punctuation, find out the frequency of each word, and print the top 5 most frequent words.
Three Rings for the Elven-kings under the sky,
Seven for the Dwarf-lords in their halls of stone,
Nine for Mortal Men doomed to die,
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
One ring to rule them all, One ring to find them,
One ring to bring them all, and in the darkness bind them,
In the land of mordor where the shadows lie.
Dataset:
info.log
2025-08-21 12:00 User login
2025-08-21 12:02 File uploaded
2025-08-21 12:04 User logout
error.log
2025-08-21 12:01 DB timeout
2025-08-21 12:03 Disk full
2025-08-21 12:04 Failed logout
Goal: Merge INFO + ERROR into a single chronologically sorted and labled log.
Expected Output:
2025-08-21 12:00 [INFO] User login
2025-08-21 12:01 [ERROR] DB timeout
2025-08-21 12:02 [INFO] File uploaded
2025-08-21 12:03 [ERROR] Disk full
2025-08-21 12:04 [INFO] User logout
2025-08-21 12:04 [ERROR] Failed logout
Goal: You need to fetch weather data from a public API and extract specific information using bash tools. Write a one-liner that fetches weather data from https://api.openweathermap.org/data/2.5/weather?q=London&appid=demo&units=metric and extracts only the temperature value (rounded to nearest integer).
Example API Response:
{
"coord": {
"lon": -0.1257,
"lat": 51.5085
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
"main": {
"temp": 15.32,
"feels_like": 14.25,
"temp_min": 13.89,
"temp_max": 16.67
},
"name": "London"
}
Test Cases:
- Valid API Response: Extract temperature from valid JSON response
- Different Temperature Values: Test with various temperature values
- Network Error Handling: Handle cases when API is unreachable
- Invalid JSON: Handle malformed JSON responses gracefully
Dataset:
product A is 10kg, very heavy
product B is 250g.
product C is 1kg
product D is 500g
product E is only 2mg
Goal: Extract only the numeric values for entries ending with g, but exclude kg and mg.
Expected output:
250
500
Goal: You need to scan a range of ports on localhost to find which services are running. Write a one-liner bash command that checks ports 3000, 3001, 3002, 3003, and 3004 on localhost and outputs only the open ports in the format "Port X is open".
Expected output:
Port 3000 is open
Port 3004 is open
Test Cases:
1. Multiple Open Ports: Test when several ports are open
2. No Open Ports: Test when none of the target ports are open
3. All Ports Open: Test when all target ports are open
4. Single Port Open: Test when only one port is open