-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.sh
More file actions
49 lines (37 loc) · 1.27 KB
/
Copy pathsolution.sh
File metadata and controls
49 lines (37 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# 1. Sort the contents of "numbers.txt" in ascending order
# Your command here
sort numbers.txt
# 2. Print the IP address of the machine
# Your command here
hostname -I
# 3. Show the contents of a file named "readme.txt" in the current directory
# Your command here
cat readme.txt
# 4. Count the number of lines in "data.csv"
# Your command here
wc -l data.csv
# 5. Find all files containing the word "error" in the "logs" folder
# Your command here
grep -r "error" logs/
# 6. Display the last 10 lines of "app.log"
# Your command here
tail -n 10 app.log
# 7. Change permissions of "script.sh" to make it executable for everyone
# Your command here
chmod a+x script.sh
# 8. Use a command to search for the word "TODO" in every ".py" file in the current directory
# Your command here
grep -n "TODO" *.py
# 9. Show the last 20 commands entered in the terminal
# Your command here
history | tail -n 20
# 10. Show processes sorted by memory usage
# Your command here
ps aux --sort=-%mem
# 11. Find all directories named "backup" anywhere on the system
# Your command here
find / -type d -name "backup" 2>/dev/null
# 12. Replace every occurrence of "foo" with "bar" in "example.txt" and save to "new_example.txt"
# Your command here
sed 's/foo/bar/g' example.txt > new_example.txt