123343067-Quiz.doc

Answer for i in foodo mv i ifoobardone question 7

  • No School
  • AA 1
  • 32

This preview shows page 22 - 25 out of 32 pages.

Answer: for i in ./*foo*;do mv “$i” “${i/foo/bar}”;done # Question 7: Show the most commonly used commands from “history”. [hint: remember the history command, use cut, and sort it. Answer: history|sort|cut -d ‘ ‘ -f1 TCS ASPIRE : Unix Assignment 2 quiz answers 2012 # Question 1: 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 ‘se’. 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? Answer : To navigate from 'se' to home directory,in one step,the command is : cd To navigate from 'se' to 'sdp',in one step,the command is : cd ../b # Question 2: How will you copy a directory structure dir1 to dir2 ? (with all the subdirectories) Answer : cp –R dir1 dir2 # Question 3: How can you find out if you have the permission to send a message? Answer : ls -l ( To check access permissions)
Image of page 22

Subscribe to view the full document.

# Question 4: Find the space occupied ( in Bytes) by the /home directory including all its subdirectories. Answer : du -s -b # Question 5: What is the command for printing the current time in 24-hour format? Answer : date +%T # Question 6: 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. Answer : The general syntax is : cat > filename Type the contents of file Press Ctrl+D Example: cat > chapa Type the contents of file Ctrl+D # Question 7: What is the command for printing the year, month, and date with a horizontal tab between the fields? Answer : date +%Y%t%B%t%e # Question 8: With reference to question 7, What is the command for listing all files ending in small letters? Answer : find –name “*[a-z].*” # Question 9: With reference to question 7, What is the command for listing all files ending in capitals? Answer : find –name “*[A-Z].*”
Image of page 23
# Question 9: With reference to question 7, What is the command for listing all files ending in small letters? Answer : find –name “*[a-z].*” # Question 10: With reference to question 7, What is the command for listing all files whose last but one character is 0? Answer : find –name “*0?.*” # Question 11: With reference to question 7, What is the command for listing all files which end in small letters but not ‘a’ and ‘c’? Answer : find –name “*[b d-z].*” # Question 12: 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? Answer : grep -c "programmers" personnel # Question 13: In the organisation mentioned in question 12 how can sed be used to print only the records of all employees who are programmers.
Image of page 24

Subscribe to view the full document.

Image of page 25

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern