You are on page 1of 6

Practice 3

Download file rolllist.txt from http://www.cs.gsu.edu/~cscyip/csc3320/rolllist.txt, search and sort of this file.

1. search Web grep Web rolllist.txt

2. search word Web and list the line number grep wn Web rolllist.txt

3. display lines without Web grep v Web rolllist.txt

4. display lines which start with A,B,C, or D. grep ^[A-D] rolllist.txt

5. display lines which dont start with A,B,C, or D. grep ^[^A-D] rolllist.txt

6. display lines which end with s grep s$ rolllist.txt

7. display lines which include at least 2 successive 1 egrep 111* rolllist.txt egrep 11+ rolllist.txt 8. search lines which include Vi or Br

egrep Vi|Br rolllist.txt

9. search lines which include at least 6 0 egrep .*0.*0.*0.*0.*0.*0.* rolllist.txt

10. search lines which include 03 or 033 egrep 033? rolllist.txt

11. sort file sort rolllist.txt

12. sort it in reverse order sort r rolllist.txt

13. sort on second field sort +1 -2 rolllist.txt

14. set , as separator, sort on second field sort t, +1 -2 rolllist.txt

15. set . As separator , sort on the third field by numeric order sort t. +2 -3 n rolllist.txt

cat > file1 How are you?

See you. See you later.

cat > file2 Hi, How are you? See you. See you Later. Dialog A

cat > file3 How are you? see you. See you later.

16. compare file1 and file3

17. display the differences between file1 and file3 (try ignore case)

18. display the differences between file1 and file2 (try ignore case)

19. find c source files in the current directory or any of its subdirectories find . name *.c

20. find java source files in your home directory find $HOME name *.java

21. grant all exe files (extended name is exe) in the current directory or its subdirectories permission 777 find . -name '*.exe' -ls -exec chmod 777 {} \;

22. create a hard link file1link for file1 ln file1 file1link

23. display the hard link count for file1 and file1link ls -l file1 file1link

24. remove file1 rm file1

25. display the hard link count for file1link ls l file1link

26. create a soft link file1 for file1link ln s file1link file1

27. use ls l display attributes of file1 and file1link ls -l file1 file1link

28. remove file1link

rm file1link

29. display the content of file1 cat file1

30. use ls-l display file1 ls l file1

31. create a directory tartest in your home directory mkdir ~/tartest

32. copy all files and directories in your home directory into tartest cp r ~/* ~/tartest

33. archive tartest to tartest.tar tar cvf tartest.tar ~/tartest

34. archive tartest to tartest1.tar with gzip option tar zcvf tartest1.tar ~/tartest 35. display file size of tartest.tar and tartest1.tar ls l tartest.tar tartest1.tar

36. archive the current directory to current.tar tar cvf current.tar .

37. create a directory tartest2 in your home directory

mkdir ~/tartest2

38. extract tartest.tar tar xvf tartest.tar

39. copy tartest1.tar to tartest2 and extract tartest1.tar in tartest2 cp tartest1.tar ~/tartest2 cd ~/tartest2 tar zxvf tartest1.tar

You might also like