Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Operating Systems > Linux, Unix

Reply
 
LinkBack Thread Tools
Old 10-04-05   #1 (permalink)
Intel Overclocker
 
intel nvidia

Join Date: Jul 2005
Location: Vancouver
Posts: 100

Rep: 3 c_loke Unknown
Unique Rep: 3
Trader Rating: 0
Default UNIX Help

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)?
__________________
System: My System
CPU
Intel Core 2 Duo E6400 @ 3.2ghz Lapped
Motherboard
Asus P5B Deluxe w/ WiFi
Memory
2 X 2.0 gig OCZ Reaper Hpc Edition PC2 8500
Graphics Card
EVGA 8800 GTS 320mb Superclocked
Hard Drive
Seagate 320 gig
Sound Card
Creative X-Fi Platnium
Power Supply
OCZ GameXStream 600W
Case
Antec Sonata 2
CPU cooling
Xigmatek HDT S1283
OS
Vista Home Edidition 64 bit
Monitor
22'' Samsung 226bw
c_loke is offline   Reply With Quote
Old 10-04-05   #2 (permalink)
Linux Lobbyist
 
kopeah's Avatar
 
amd nvidia

Join Date: Jun 2005
Location: San Antonio, TX
Posts: 139

Rep: 25 kopeah is acknowledged by some
Unique Rep: 18
FAQs Submitted: 3
Trader Rating: 0
Default

Quote:
Originally Posted by c_loke
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?
File with most words, basically the first 10 largest file.

Code:
ls -lS *
Quote:
Originally Posted by c_loke
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)?
If Judy and Jill belong to the same group,

Code:
chmod g+r SharedStuff
if not

Code:
chmod o+r SharedStuff
But then, this also depends on how the system has been configured. If /home/nitro is configured with only user have read,write,and execute then Jill is SoL.

__________________
System: My System
CPU
Athlon 64 X2 6000+
Motherboard
EVGA 590 SLI
Memory
4 GB
Graphics Card
8800 GTS
Sound Card
Integrated Ac97
Power Supply
Ultra-X 500W
Case
Antec Nine
OS
Gentoo + Vista (games)
Monitor
LG FLatron 22"
kopeah is offline   Reply With Quote
Old 10-04-05   #3 (permalink)
Intel Overclocker
 
intel nvidia

Join Date: Jul 2005
Location: Vancouver
Posts: 100

Rep: 3 c_loke Unknown
Unique Rep: 3
Trader Rating: 0
Default

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.
__________________
System: My System
CPU
Intel Core 2 Duo E6400 @ 3.2ghz Lapped
Motherboard
Asus P5B Deluxe w/ WiFi
Memory
2 X 2.0 gig OCZ Reaper Hpc Edition PC2 8500
Graphics Card
EVGA 8800 GTS 320mb Superclocked
Hard Drive
Seagate 320 gig
Sound Card
Creative X-Fi Platnium
Power Supply
OCZ GameXStream 600W
Case
Antec Sonata 2
CPU cooling
Xigmatek HDT S1283
OS
Vista Home Edidition 64 bit
Monitor
22'' Samsung 226bw
c_loke is offline   Reply With Quote
Old 10-05-05   #4 (permalink)
Linux Lobbyist
 
kopeah's Avatar
 
amd nvidia

Join Date: Jun 2005
Location: San Antonio, TX
Posts: 139

Rep: 25 kopeah is acknowledged by some
Unique Rep: 18
FAQs Submitted: 3
Trader Rating: 0
Default

Quote:
Originally Posted by c_loke
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.
Oops ..the first answer would be

Code:
ls -lS *.essay
__________________
System: My System
CPU
Athlon 64 X2 6000+
Motherboard
EVGA 590 SLI
Memory
4 GB
Graphics Card
8800 GTS
Sound Card
Integrated Ac97
Power Supply
Ultra-X 500W
Case
Antec Nine
OS
Gentoo + Vista (games)
Monitor
LG FLatron 22"
kopeah is offline   Reply With Quote
Old 10-05-05   #5 (permalink)
Intel Overclocker
 
intel nvidia

Join Date: Jul 2005
Location: Vancouver
Posts: 100

Rep: 3 c_loke Unknown
Unique Rep: 3
Trader Rating: 0
Default

thanks man.
*rep 4 u
__________________
System: My System
CPU
Intel Core 2 Duo E6400 @ 3.2ghz Lapped
Motherboard
Asus P5B Deluxe w/ WiFi
Memory
2 X 2.0 gig OCZ Reaper Hpc Edition PC2 8500
Graphics Card
EVGA 8800 GTS 320mb Superclocked
Hard Drive
Seagate 320 gig
Sound Card
Creative X-Fi Platnium
Power Supply
OCZ GameXStream 600W
Case
Antec Sonata 2
CPU cooling
Xigmatek HDT S1283
OS
Vista Home Edidition 64 bit
Monitor
22'' Samsung 226bw
c_loke is offline   Reply With Quote
Old 10-10-05   #6 (permalink)
Retired Section Director
 
Xaimus's Avatar
 
amd nvidia

Join Date: Dec 2004
Posts: 576

Trader Rating: 0
Default

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
second:
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
Xaimus is offline Overclocked Account   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 12:08 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.14407 seconds with 8 queries