OS_Lab_Assignment_III_PartB_QA
OS_Lab_Assignment_III_PartB_QA
Q3. 3. Show the calendar of the 9th month of the year 2009.
cal 09 2009
Q5. 5. Display a full weekday name, full month name, day of the year, hour
date '+%A, %B %d, %j, %H:%M'
Q6. 6. Create a file to store information about your college. Display the content of file. Show only first
4 lines of the file. Show also only last 3 lines of the file.
echo 'Your College Info' > college.txt
cat college.txt
head -n 4 college.txt
tail -n 3 college.txt
Q7. 7. To append one file to another i.e. to copy the content of file1 to file2 (at the end of file2).
cat file1 >> file2
Q16. 16. List all files with single character or double character extension.
ls *.? *.??
Q17. 17. In a file perform (i) Line count (ii) Word count (iii) Character count
wc -l filename
wc -w filename
wc -c filename
Q19. 19. List all files, which are not started with t but s.
ls | grep -v '^t' | grep '^s'
Q24. 22. Create a file using vi editor and perform given actions
vi file.txt
# Use vi commands:
# i (insert), :w (save), :set number, o (new line), x (delete char), dd (delete line), u
(undo), /search, :s/old/new/
# Practice required in vi editor.
Q28. 32. Create one hidden file and show all the hidden files.
touch .hiddenfile
ls -a
Q29. 33. Create file1, file2 and file3 using a single command.
touch file1 file2 file3