This question is about the UNIX or LINIX, someone can give me some idea about ho
ID: 3869719 • Letter: T
Question
This question is about the UNIX or LINIX, someone can give me some idea about how to do this. Thx
4) (10 marks) The answers to this question should be created using the command script recording to the files a2q4a.txt and a2q4b.txt, and submitted through SVN. The conm mands must be run on bluenose a) (5 marks) Write a command line that lists all files in the directory/etc that end with a dot ('.') and three characters and the end. Avoid printing contents of the directories by using the option -d of the command ls. Use the long format of the ls command, but only the part form the file size, and the output must be sorted by file size in the increasing order. You can use commands 1s, cut, and sort. Your answer should be correct if you get the following output (a long line is truncated) 22 Dec 9 2015 /etc/issue.net 22 Nov 18 2016/etc/grub2.cfg -> ../boot/grub2/grub.cfg 56 Nov 18 2016/etc/favicon.png -> /usr/share/icons/hicolor/16x16/.. . 75 Aug 12 2015/etc/munin.rpm 314 Jan 18 2016 /etc/fppkg . bak 314 Jan 18 2016 /etc/fppkg.cfg 375 Sep 28 2016 /etc/trusted-key.key 1757 Aug 12 2015 /etc/nsswitch.conf.bak 7852 Jan 18 2016 /etc/fpc.cfg 8230 Jan 18 2016/etc/fpc.bak 67106 Nov 10 2016 /etc/php.ini b) (5 marks) Write a command line that processes file /etc/passwd, in which fields in each line are separated by colon (:), and prints out its 1st and 3rd filed (username and userid) in each line of output. The output should be sorted numerically by the userid. You can use only the commands cut and sort.Explanation / Answer
a) ls -lds /etc/*.??? | cut -f 8- -d ' '
-l is used for long form,
-d is used to remove directories from list
-s is used to sort the result by size.
Cut command is used to supress other unwanted stuff from the the result like permissions.
b) sort -t: -k 3,4 -g /etc/passwd | cut -d: -f1,3,4 /etc/passwd
cut is used to only unclude username and user id
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.