|
|
|
#1 (permalink) | ||||||||||||
|
Intel Overclocker
|
Hey, im stuck for two UNIX questions on my assignment. Can you guys give me a hand?
__________________Question 1: Gene has a large directory structure of .essay files, where he has saved all of the essays that he has done over his academic career. Not all of the .essay files are in the same directory (he organized them and put them in subdirectories). He wants to find out which 10 essays he has written have the most words. What one line command would he have to run to find out? Question 2: Judy has a directory in her home direictory that she wants to share with her friend Jill. Judy's username is nitro (hence her home directory is /home/nitro), and the directory she wants to share is SharedStuff. What command(s) will Judy have to run so that Jill can get access to read the contents of the SharedStuff directory (but no other directory)?
|
||||||||||||
|
|
|
|
|
#2 (permalink) | ||||||||||||
|
Linux Lobbyist
![]() |
Quote:
Code:
ls -lS * Quote:
Code:
chmod g+r SharedStuff Code:
chmod o+r SharedStuff
|
||||||||||||
|
|
|
|
|
#3 (permalink) | ||||||||||||
|
Intel Overclocker
|
ok my teacher is a fool. he just updated the information to include this to the first question.
__________________does it change my answer? (note: * is a wildcard that represents every file (so *.java would represent every file that ends in .java)) NOTE: The files being examined are those with file names like knuth.essay, ruskey.essay, world.essay, etc. You may assume that there are no subdirectories of subdirectories and that you are currently in the top-level directory that contains any .essay files. The unix command "wc" should prove useful.
|
||||||||||||
|
|
|
|
|
#4 (permalink) | |||||||||||
|
Linux Lobbyist
![]() |
Quote:
Code:
ls -lS *.essay
|
|||||||||||
|
|
|
|
|
#5 (permalink) | ||||||||||||
|
Intel Overclocker
|
thanks man.
__________________*rep 4 u
|
||||||||||||
|
|
|
|
|
#6 (permalink) |
|
Retired Section Director
![]() |
first:
find . -iname "*.essay" -print0 | xargs -0 wc -w | sort -r | tail -n +2 | head -n 10 This will find all files in all subdirectories that end with .essay, pipe the output to wc -w, sort the results in descending order, cut out the first line of cruft (the total count), and only display 10 results. find . -iname "*.essay" -print0 | xargs -0 wc -w | sort -r would work just as well, if wc reports results in a different format. Examples of execution: Code:
imran@pandora:~/Programming/CIS300$ find . -iname "*.java" -print0 | xargs -0 wc -w | sort -r | tail -n +2 | head -n 10
544 ./Project 2/xaimus/ArrayList.java
528 ./Project 2/xaimus/LinkedList.java
422 ./Project 2/xaimus/Test.java
408 ./Project 1/xaimus/ArrayList.java
330 ./Project 2/xaimus/Main.java
256 ./Project 2/xaimus/ConsoleIO.java
256 ./Project 1/xaimus/ConsoleIO.java
233 ./Project 1/xaimus/Main.java
232 ./Project 2/xaimus/GraphicIO.java
232 ./Project 1/xaimus/GraphicIO.java
Code:
imran@pandora:~/Programming/CIS300$ find . -iname "*.java" -print0 | xargs -0 wc -w | sort -r
4045 total
544 ./Project 2/xaimus/ArrayList.java
528 ./Project 2/xaimus/LinkedList.java
422 ./Project 2/xaimus/Test.java
408 ./Project 1/xaimus/ArrayList.java
330 ./Project 2/xaimus/Main.java
256 ./Project 2/xaimus/ConsoleIO.java
256 ./Project 1/xaimus/ConsoleIO.java
233 ./Project 1/xaimus/Main.java
232 ./Project 2/xaimus/GraphicIO.java
232 ./Project 1/xaimus/GraphicIO.java
204 ./Project 2/xaimus/List.java
138 ./Project 1/xaimus/List.java
131 ./Project 2/xaimus/IO.java
131 ./Project 1/xaimus/IO.java
Judy could use setfacl to allow Judy and only Judy access to her homedir, or she could enable the world-readable/executable and group-readable/executable bits in her homedir. Additionally, she would need to set the world-executable and group-executable bits in all parent directories: chmod 711 ~ chmod 755 ~/SharedStuff edit: typos edit again: holy **** i'm over a week late Last edited by Xaimus : 10-12-05 at 11:51 AM |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|