TCS ASPIRE : UNIX ASSIGNMENT NO:2

Create a tree structure named 'training' in which there are 3 subdirectories - 'level 1',' level2' and 'cep'. Each one is again further divided into 3. The 'level 1' is divided into 'sdp', 're' and 'e'. From the subdirectory 'se' how can one reach the home directory in one step and also how to navigate to the subdirectory 'sdp' in one step? Give the commands, which do the above actions?
        navigate from ‘se’ to home – cd ~
        navigate directly to sdp – cd training/level1/sdp

·        How will you copy a directory structure dir1 to dir2 ? (with all the subdirectories) 
        cp –R dir1 dir2

·        How can you find out if you have the permission to send a message? 
 
        ls -l
·        Find the space occupied ( in Bytes) by the /home directory including all its subdirectories.

         du -sb 
·        What is the command for printing the current time in 24-hour format?

       date ‘+%R’
·        What is the command for printing the year, month, and date with a horizontal tab between the fields?
date ‘+%R’
·        Create the following files: chapa, chapb, chapc, chapd, chape, chapA, chapB, chapC, chapD, chapE, chap01, chap02, chap03, chap04, chap05, chap11, chap12, chap13, chap14, and chap15.
Cat > chapa
Contents of file
Ctrl+D

Cat > chapb
Contents of file
Ctrl+D

Cat > chapc
Contents of file
.
.
.
Cat> chap15
Contents of file
Ctrl+D

·        With reference to question 7, What is the command for listing all files ending in small letters?

       find . –name “*[a-z].*”
·        With reference to question 7, What is the command for listing all files ending in capitals? 

          find . –name “*[A-Z].*”
·        With reference to question 7, What is the command for listing all files whose last but one character is 0? 

         find . –name “*0?.*”
·        With reference to question 7, What is the command for listing all files which end in small letters but not 'a' and 'c'? 

          find . –name “*[b d-z].*”
·        In an organisation one wants to know how many programmers are there. The employee data is stored in a file called 'personnel' with one record per employee. Every record has field for designation. How can grep be used for this purpose? 

          $ grep -c programmer personnel
·        In the organisation mentioned in question 12 how can sed be used to print only the records of all employees who are programmers. 

       $ sed -n "/programmer/p" personnel
·        In the organisation mentioned in question 12 how can sed be used to change the designation 'programmer' to 'software professional' every where in the 'personnel' file 

       $ sed -e "s/programmer/software professional/g" personnel

·        Find out about the sleep command and start five jobs in the background, each one sleeping for 10 minutes.

         $ sleep 10 & sleep 10 & sleep 10 & sleep 10 & sleep 10 &

·        How do you get the status of all the processes running on the system? i.e. using what option?
  
      $ ps -e
IF you have More Question Share in Comment

No comments:

Post a Comment