Table of contents
- DAY 3 :- TASK
- 1. View the content of a file and display line numbers.
- 2. Change the access permissions of files to make them readable, writable, and executable by the owner only.
- 3. Check the last 10 commands you have run.
- 4. Remove a directory and all its contents.
- 5. Create a fruits.txt file, add content (one fruit per line), and display the content.
- 6. Add content in devops.txt (one in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava. Then, append "Pineapple" to the end of the file.
- 7. Show the first three fruits from the file in reverse order.
- 8. Show the bottom three fruits from the file, and then sort them alphabetically.
- 9. Create another file Colors.txt, add content (one color per line), and display the content.
- 11. Find and display the lines that are common between fruits.txt and Colors.txt.
- 12. Count the number of lines, words, and characters in both fruits.txt and Colors.txt.
DAY 3 :- TASK
1. View the content of a file and display line numbers.
cat -n #filename
2. Change the access permissions of files to make them readable, writable, and executable by the owner only.
chmod 777 #filename
3. Check the last 10 commands you have run.
history | tail -10
4. Remove a directory and all its contents.
rm -r #directoryname
5. Create a fruits.txt
file, add content (one fruit per line), and display the content.
touch fruits.txt #creating file
vim fruits.txt #editing file as one fruite per line
cat fruits.txt #display the content
6. Add content in devops.txt
(one in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava. Then, append "Pineapple" to the end of the file.
vim fruits.txt #editing file as one fruite per line
cat fruits.txt #display the content
echo "pineapple" >> fruits.txt #adding pineapple in last of fruits.txt
cat fruits.txt #display the content
7. Show the first three fruits from the file in reverse order.
head -3 #filename | tac
8. Show the bottom three fruits from the file, and then sort them alphabetically.
tail -3 #filename | sort
9. Create another file Colors.txt
, add content (one color per line), and display the content.
vim #file name
cat #file name
11. Find and display the lines that are common between fruits.txt
and Colors.txt
.
comm -12 <(sort *filename1) <(sort *filename2)
12. Count the number of lines, words, and characters in both fruits.txt
and Colors.txt
.
wc #file name
Thank you for reading!
© 2024 Anand Raval. All rights reserved.