Beruflich Dokumente
Kultur Dokumente
2. Sort in reverse order the contents of the infile1 and infile 2 placing the output in outfile
and using the first character of the second field as the sort key.
Ans : sort -r -o outfile -k 2.1,2.2 infile1 infile2
4. Provide a numbered listing of all files in your directory in reverse order and print from
7th line
ls -r | nl > new.txt | head -n7 new.txt
| tail -6 new.txt
7 kaushik
8 KAUSHI
9 fork.c~
10 fork.c
12 a.out
5. Display all lines in a file which contain the word “World all occurrences like
world,World,WOrld,WORld….ignore case option” from a file. Report is not allowed.
this World
this world
WoRld
worlD
WORLD
woRLd
=#$%^&*()
uytfi8r7=656;;5tyuygioupw02#$%^&*();;
this WORLD
this WORLD
tead
worlli
WORLD
WORLD
WORLD
WORLD
Create a file emp with name,ssn,age,salary,dept.
ii. List the employees who earn between 4000 and 6000
iii. Locate only the marketing dept employees
grep market emp.txt
iv. list the duplicated records of the file with the frequency of occurrence and
dump them into a file called dup.(use uniq and sort filter)
cat emp.txt| sort -k 5|uniq -f 1 >dup.txt
v. Sort the file on the employee codes and extract the basic and names of the
non-duplicated lines
cat emp.txt| sort -k 2|uniq -f 1 |cut -f 4,1 -d " "
kiran 4000
harsha 5000
kushal 8990
9. Frame a grep command which locates the people from emp database having the same
month of birth as the current month.
grep -i `date +%b` emp.txt
11. From emp file retrieve the records with designation as director and salary > 7600.
12. Devise a pipeline to locate the user who logged in first (assuming they all logged in the
same month) and extract only the log in id.
who | sort -k 4 | head -n 1 |cut -f 1 -d “ “
13. Write a command sequence which displays every file in the system having a size larger
than 100 KB. Ans. find -size +100k
/oslab prhs/os-labwork.pdf
./packages/aptoncd-20090906-CD1.iso
./packages/aptoncd-20090713-CD1.iso
./packages/aptoncd-20091004-CD1.iso
./packages/aptoncd-20091008-CD1.iso
./packages/aptoncd-20090710-DVD1.iso
./packages/aptoncd-20091012-CD1.iso
/kaushik/Eploit writing tutorial part 1 Stack Based Overflows Peter Van Eeckhoutte's
Blog_files/image50_thumb.png
14. Use a filter to extract file access permission’s and file name and paste it in another file
logevent.
packages:700
aptoncd-20090906-CD1.iso:700
aptoncd-20090713-CD1.iso:700
aptoncd-20091004-CD1.iso:700
aptoncd-20091008-CD1.iso:700
aptoncd-20090710-DVD1.iso:700
aptoncd-20091012-CD1.iso:700
15. Write a filter to remove all colon’s in a file and display it.
cat alpnum.txt | tr -d [=:=]
uytfi8r7=656..5tyuygioupw02#$%^&*()..98709uy7tgiu8
16. Write a tool to check whether the number of open braces are equal to number of close
braces in a C program file Write a filter to remove all colon’s in a file and display it.