Unix Command Practice Assignment – 1


Assignment – 1 1)create the directory structure under your home directory /subject/cmsa /subject/phsa /subject/mtma /subject/cmsa/third in a single command Ans: [cmsa1@localhost ~]$ mkdir subject subject/cmsa subject/phsa subject/mtma subject/cmsa/third 2) create three blank files a1.txt,a2.txt,a3.txt under directory third in a single command Ans: [cmsa1@localhost third]$ touch a1.txt a2.txt a3.txt 3) copy the file a1.txt into directory cmsa and mtma Ans:[cmsa1@localhost third]$ cp a1 .. [cmsa1@localhost third]$ cp a1 ../../mtma 4) Write content to the 3 files.compare the files a1.txt and a2.txt Ans:[cmsa1@localhost third]$ cmp a1 a2 5) Show the common lines between a1.txt and a2.txt Ans:[cmsa1@localhost third]$ sort a1>x1 [cmsa1@localhost third]$ sort a2>x2 [cmsa1@localhost third]$ comm -12 x1 x2 6) show only the files under your home directory Ans:[cmsa1@localhost third]$ find . -maxdepth 1 -type f 7) Print the lines in files under directory third that doesn’t contain the word UNIX or unix. Ans:[cmsa1@localhost third]$ grep -v -e "UNIX" -e "unix" * 8) Rename all .txt files to .bak files under directory third. Ans:[cmsa1@localhost third]$ rename .txt .bak *.txt

Share:

0 comments