In: Computer Science
Use linux
Original question:
d) Use metacharacters and the ls -lL command (with lower and
upper case L) to list all filenames under the datafiles
directory that contain a dot '.' with the letter 'f' or 'u'
anywhere after the dot.
e) Use metacharacters and a single ls -lL command (with lower and
upper case L) to listall file names that contain a dot '.' followed
by a lower case letter, then end with the letter 't' or 'r' as the
second from last character. And these files should be from your
current directory as well as any directory under the current
directory that contains the letters "data".
For example: data1/a.pqrs would be a match, but dabta.Dtu and
datafiles/.softdo not match.
Hint: use two command arguments, one for the
current directory, and one for directories the contain 'data'.
Instructure sample output:
d)
-rwx------ 1 rpa b20003 2401 Sep 5 14:15
datafiles/famous.backup
-rwx------ 2 rpa b20003 2401 Sep 5 14:25
datafiles/famous.soft
e)
-rwx------ 2 rpa b20003 2401 Sep 5 14:25
datafiles/famous.hard
-rwx------ 2 rpal b20003 2401 Sep 5 14:25 famous.data
What I have so far:
[dfoote1$$$$$$ bin]$ ls -lL /students/dfoote1/bin/datafiles/*.*[fu]* -rwx------ 1 dfoote1 students 2401 Sep 17 17:45 /students/dfoote1/bin/datafiles/famous.backup -rwx------ 2 dfoote1 students 2401 Sep 17 16:15 /students/dfoote1/bin/datafiles/famous.soft [dfoote1$$$$$$ bin]$ ls -ll /students/dfoote1/bin/datafiles/*.*[fu]* -rwx------ 1 dfoote1 students 2401 Sep 17 17:45 /students/dfoote1/bin/datafiles/famous.backup lrwxrwxrwx 1 dfoote1 students 33 Sep 17 17:40 /students/dfoote1/bin/datafiles/famous.soft -> /students/dfoote1/bin/famous.data
Answer d)
What ever you have done is correct.
Answer e)
ls *.[[:lower:]]*[tr]? *data*/*.[[:lower:]]*[tr]
In the above command i use * for any character as first name, then . then i[[:lower:]] means the character after . is lower case letter, then * means any character with any length, then [tr] means then second last character with either t or r, ? means the last character will be any. I give 2 times the same expression , one for current directory and other for directory contains data as the word.
Screenshot