Linux Tuts - PIPES - Question 10

Problem completing one of the interactive tutorials?

Moderator: drgrussell

Post Reply
rotten

Linux Tuts - PIPES - Question 10

Post by rotten » Mon Oct 13, 2014 1:51 am

Greetings!

Reviewing the past tutorials for questions that i haven't passed, i found question 10 of linux tutorial:
Use ls -l and grep to find all the files in /etc that were last modified in Jun. Sort this list in descending order of size and send the output to s7.
I'm using option -S of ls to accomplish what the question asks:

Code: Select all

[demo@host-6-57 ~]$ ls -lS /etc | grep Jun > s7; cat s7
-rw-r--r--.  1 root root   670293 Jun  7  2013 services
-rw-r--r--.  1 root root    25213 Jun  9 21:30 dnsmasq.conf
-rw-r--r--.  1 root root    21929 Jun 10 04:59 brltty.conf
-rw-r--r--.  1 root root     8892 Jun 10 05:47 nanorc
-rw-r--r--.  1 root root     6545 Jun  7  2013 protocols
-rw-r--r--.  1 root root     6300 Jun 10 00:07 pnm2ppa.conf
-rw-r--r--.  1 root root     5171 Jun  9 22:35 man_db.conf
-rw-r--r--.  1 root root     4922 Jun 10 02:42 oddjobd.conf
-rw-r--r--.  1 root root     4760 Jun  9 21:10 enscript.cfg
-rw-r--r--.  1 root root     4479 Jun  9 22:43 wgetrc
-rw-r--r--.  1 root root     3580 Jun 10 00:55 idmapd.conf
-rw-r--r--.  1 root root     3390 Jun 10 06:45 nfsmount.conf
-rw-r--r--.  1 root root     3095 Jun 10 04:31 drirc
-rw-r--r--.  1 root root     2872 Jun 10 05:22 pinforc
-rw-r--r--.  1 root root     2835 Jun 10 03:04 bashrc
-rw-r--r--.  1 root root     2620 Jun 10 09:54 mtools.conf
-rw-r--r--.  1 root named    2389 Jun 10 09:13 named.iscdlv.key
-rw-r--r--.  1 root root     2000 Jun 18 22:13 ntp.conf
-rw-r--r--.  1 root root     1982 Jun 10 07:56 vimrc
-rw-r--r--.  1 root root     1982 Jun 10 07:56 virc
-rw-r--r--.  1 root root     1968 Jun  9 22:30 mail.rc
-rw-r--r--.  1 root root     1787 Jun 10 03:17 request-key.conf
-rw-r--r--.  1 root root     1750 Jun  7  2013 profile
-rw-r--r--.  1 root root     1602 Jun  7  2013 csh.cshrc
-rw-r--r--.  1 root root     1518 Jun  7  2013 aliases
-rw-r--r--.  1 root root     1362 Jun 10 00:07 pbm2ppa.conf
-rw-r--r--.  1 root root     1330 Jun 10 01:08 colord.conf
-rw-r--r--.  1 root root     1317 Jun 10 05:13 ethertypes
-rw-r--r--.  1 root root     1285 Jun 12 17:59 dracut.conf
-rwxr-xr-x.  1 root root     1260 Jun 10 08:42 auto.net
-rw-r--r--.  1 root root     1165 Jun 18 22:15 chrony.conf
-rw-r--r--.  1 root root      970 Jun 27 12:07 yum.conf
-rw-r--r--.  1 root root      942 Jun  7  2013 inputrc
-rw-r--r--.  1 root root      936 Jun  9 20:59 mke2fs.conf
-rw-r-----.  1 root named     931 Jun 21  2007 named.rfc1912.zones
-rw-r--r--.  1 root root      841 Jun  7  2013 csh.login
-rw-r--r--.  1 root root      767 Jun 10 09:52 netconfig
-rw-r--r--.  1 root root      724 Jun 10 08:42 auto.master
-rwxr-xr-x.  1 root root      687 Jun 10 08:42 auto.smb
-rw-r--r--.  1 root root      676 Jun  9 22:49 cgconfig.conf
-rw-r--r--.  1 root root      570 Jun 23 21:55 my.cnf
-rw-------.  1 root root      541 Jun  9 22:33 anacrontab
-rw-r--r--.  1 root root      524 Jun 10 08:42 auto.misc
-rw-r--r--.  1 root root      460 Jun  7  2013 hosts.deny
-rw-r--r--.  1 root root      458 Jun 10 03:47 rsyncd.conf
-rw-r--r--.  1 root root      451 Jun  9 23:14 crontab
-rw-r--r--.  1 root root      433 Jun 10 05:43 radvd.conf
-rw-r--r--.  1 root root      375 Jun 10 09:13 trusted-key.key
-rw-r--r--.  1 root root      370 Jun  7  2013 hosts.allow
-rw-r--r--.  1 root root      256 Jun 21 17:47 sos.conf
-rw-r--r--.  1 root root      233 Jun  7  2013 printcap
-rw-------.  1 root root      232 Jun 10 08:42 autofs_ldap_auth.conf
-rw-r--r--.  1 root root      216 Jun 10 07:16 sestatus.conf
-rw-r--r--.  1 root root      158 Jun  7  2013 hosts
-rw-r--r--.  1 root root      131 Jun  9 22:49 cgsnapshot_blacklist.conf
-rw-r--r--.  1 root root      111 Jun 10 03:06 magic
-rw-r--r--.  1 root root       64 Jun  7  2013 filesystems
drwxr-xr-x.  3 root root       54 Jun 24 14:37 selinux
-rw-r--r--.  1 root root       20 Jun 24 12:15 fprintd.conf
drwxr-xr-x.  3 root root       19 Jun 24 12:24 gnome-settings-daemon
-rw-r--r--.  1 root root        9 Jun  7  2013 host.conf
drwxr-xr-x.  2 root root        6 Jun 10 08:42 auto.master.d
drwxr-xr-x.  2 root root        6 Jun  9 23:53 chkconfig.d
drwxr-xr-x.  2 root root        6 Jun  9 23:14 cron.monthly
drwxr-xr-x.  2 root root        6 Jun  9 23:14 cron.weekly
drwxr-xr-x.  2 root root        6 Jun  9 21:30 dnsmasq.d
drwxr-xr-x.  2 root root        6 Jun 12 17:59 dracut.conf.d
drwxr-xr-x.  2 root root        6 Jun 10 06:45 exports.d
drwxr-xr-x.  2 root root        6 Jun  9 20:53 gcrypt
drwxr-xr-x.  2 root root        6 Jun 10 03:18 gnupg
drwxr-xr-x.  2 root root        6 Jun 10 09:01 libibverbs.d
drwxr-xr-x.  2 root root        6 Jun  9 20:47 multipath
drwxr-x---.  2 root named       6 Jun 10 09:13 named
drwxr-xr-x.  2 root root        6 Jun 10 02:42 oddjob
drwxr-xr-x.  2 root root        6 Jun 10 01:11 opt
drwxr-xr-x.  2 root root        6 Jun 10 05:03 popt.d
drwx------.  2 root root        6 Jun 24 14:09 sssd
drwxr-xr-x.  2 root root        6 Jun  9 19:59 subversion
drwxr-x---.  2 root root        6 Jun 10 04:49 sudoers.d
drwxr-xr-x.  2 root root        6 Jun 11 04:12 terminfo
drwxr-xr-x.  2 root root        6 Jun 10 06:58 udisks2
drwxr-xr-x.  2 root root        6 Jun 10 01:11 xinetd.d
-rw-r--r--.  1 root root        1 Jun 10 02:48 at.deny
-rw-------.  1 root root        0 Jun  9 22:33 cron.deny
-rw-r--r--.  1 root root        0 Jun 10 03:04 environment
-rw-r--r--.  1 root root        0 Jun  7  2013 exports
-rw-r--r--.  1 root root        0 Jun  7  2013 motd
-rw-r--r--.  1 root root        0 Jun 10 02:01 wvdial.conf
But when i hit the check button it fails. Then, i thought it expects only files, so I exclude directories from the output using grep -v and get the following:

Code: Select all

[demo@host-6-57 ~]$ ls -lS /etc | grep Jun | grep -v '^d' > s7; cat s7
-rw-r--r--.  1 root root   670293 Jun  7  2013 services
-rw-r--r--.  1 root root    25213 Jun  9 21:30 dnsmasq.conf
-rw-r--r--.  1 root root    21929 Jun 10 04:59 brltty.conf
-rw-r--r--.  1 root root     8892 Jun 10 05:47 nanorc
-rw-r--r--.  1 root root     6545 Jun  7  2013 protocols
-rw-r--r--.  1 root root     6300 Jun 10 00:07 pnm2ppa.conf
-rw-r--r--.  1 root root     5171 Jun  9 22:35 man_db.conf
-rw-r--r--.  1 root root     4922 Jun 10 02:42 oddjobd.conf
-rw-r--r--.  1 root root     4760 Jun  9 21:10 enscript.cfg
-rw-r--r--.  1 root root     4479 Jun  9 22:43 wgetrc
-rw-r--r--.  1 root root     3580 Jun 10 00:55 idmapd.conf
-rw-r--r--.  1 root root     3390 Jun 10 06:45 nfsmount.conf
-rw-r--r--.  1 root root     3095 Jun 10 04:31 drirc
-rw-r--r--.  1 root root     2872 Jun 10 05:22 pinforc
-rw-r--r--.  1 root root     2835 Jun 10 03:04 bashrc
-rw-r--r--.  1 root root     2620 Jun 10 09:54 mtools.conf
-rw-r--r--.  1 root named    2389 Jun 10 09:13 named.iscdlv.key
-rw-r--r--.  1 root root     2000 Jun 18 22:13 ntp.conf
-rw-r--r--.  1 root root     1982 Jun 10 07:56 vimrc
-rw-r--r--.  1 root root     1982 Jun 10 07:56 virc
-rw-r--r--.  1 root root     1968 Jun  9 22:30 mail.rc
-rw-r--r--.  1 root root     1787 Jun 10 03:17 request-key.conf
-rw-r--r--.  1 root root     1750 Jun  7  2013 profile
-rw-r--r--.  1 root root     1602 Jun  7  2013 csh.cshrc
-rw-r--r--.  1 root root     1518 Jun  7  2013 aliases
-rw-r--r--.  1 root root     1362 Jun 10 00:07 pbm2ppa.conf
-rw-r--r--.  1 root root     1330 Jun 10 01:08 colord.conf
-rw-r--r--.  1 root root     1317 Jun 10 05:13 ethertypes
-rw-r--r--.  1 root root     1285 Jun 12 17:59 dracut.conf
-rwxr-xr-x.  1 root root     1260 Jun 10 08:42 auto.net
-rw-r--r--.  1 root root     1165 Jun 18 22:15 chrony.conf
-rw-r--r--.  1 root root      970 Jun 27 12:07 yum.conf
-rw-r--r--.  1 root root      942 Jun  7  2013 inputrc
-rw-r--r--.  1 root root      936 Jun  9 20:59 mke2fs.conf
-rw-r-----.  1 root named     931 Jun 21  2007 named.rfc1912.zones
-rw-r--r--.  1 root root      841 Jun  7  2013 csh.login
-rw-r--r--.  1 root root      767 Jun 10 09:52 netconfig
-rw-r--r--.  1 root root      724 Jun 10 08:42 auto.master
-rwxr-xr-x.  1 root root      687 Jun 10 08:42 auto.smb
-rw-r--r--.  1 root root      676 Jun  9 22:49 cgconfig.conf
-rw-r--r--.  1 root root      570 Jun 23 21:55 my.cnf
-rw-------.  1 root root      541 Jun  9 22:33 anacrontab
-rw-r--r--.  1 root root      524 Jun 10 08:42 auto.misc
-rw-r--r--.  1 root root      460 Jun  7  2013 hosts.deny
-rw-r--r--.  1 root root      458 Jun 10 03:47 rsyncd.conf
-rw-r--r--.  1 root root      451 Jun  9 23:14 crontab
-rw-r--r--.  1 root root      433 Jun 10 05:43 radvd.conf
-rw-r--r--.  1 root root      375 Jun 10 09:13 trusted-key.key
-rw-r--r--.  1 root root      370 Jun  7  2013 hosts.allow
-rw-r--r--.  1 root root      256 Jun 21 17:47 sos.conf
-rw-r--r--.  1 root root      233 Jun  7  2013 printcap
-rw-------.  1 root root      232 Jun 10 08:42 autofs_ldap_auth.conf
-rw-r--r--.  1 root root      216 Jun 10 07:16 sestatus.conf
-rw-r--r--.  1 root root      158 Jun  7  2013 hosts
-rw-r--r--.  1 root root      131 Jun  9 22:49 cgsnapshot_blacklist.conf
-rw-r--r--.  1 root root      111 Jun 10 03:06 magic
-rw-r--r--.  1 root root       64 Jun  7  2013 filesystems
-rw-r--r--.  1 root root       20 Jun 24 12:15 fprintd.conf
-rw-r--r--.  1 root root        9 Jun  7  2013 host.conf
-rw-r--r--.  1 root root        1 Jun 10 02:48 at.deny
-rw-------.  1 root root        0 Jun  9 22:33 cron.deny
-rw-r--r--.  1 root root        0 Jun 10 03:04 environment
-rw-r--r--.  1 root root        0 Jun  7  2013 exports
-rw-r--r--.  1 root root        0 Jun  7  2013 motd
-rw-r--r--.  1 root root        0 Jun 10 02:01 wvdial.conf
But it still fails.

What am i missing?

Thanks in advance!

drgrussell
Site Admin
Posts: 426
Joined: Sat Feb 12, 2005 8:57 pm
Are you a robot or a human?: Human

Re: Linux Tuts - PIPES - Question 10

Post by drgrussell » Mon Oct 13, 2014 5:46 pm

Again here the tutorials are designed for the course I am teaching, which does not cover -S.
The intention here is to use sort.
The problem lies in when the sizes are identical, in which case ls and sort may have different opinions as to which order is best.
G.

rotten

Re: Linux Tuts - PIPES - Question 10

Post by rotten » Thu Oct 16, 2014 7:15 pm

Greetings, Mr. G!

I've managed to pass this one using only sort as you advised.

It was trickier because the reverse ("-r") option with the numerical "n" option didn't work. After some research i put those options "on the same level" and the magic happened =)

Once again thanks for your attention and patience!

Best Regards,
RoTTeN

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests