LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-14-2014, 07:06 PM   #1
LoganK
LQ Newbie
 
Registered: Oct 2014
Posts: 8

Rep: Reputation: Disabled
School Project Please Help


Write a script to be saved on our server as 'project1.sh' that does the following things:
Runs 1 step ever 2 seconds, displaying to the user what it is doing
Counts the number of files in the /tmp directory
Counts the number of files in the /tmp directory that end in '.log'
Counts the number of files that have a 1 character name
Saves all of the output to 'project1.data'
Displays the contents of 'project1.data' to the user when the script completes
 
Old 10-14-2014, 07:10 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,026

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
what have you tried and where are you stuck ?
 
Old 10-14-2014, 07:21 PM   #3
LoganK
LQ Newbie
 
Registered: Oct 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
This is what I have so far...

ls /tmp | wc -l
sleep 2
ls /tmp | grep .log
 
Old 10-14-2014, 07:24 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,026

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
Code:
ls -1 /tmp | wc -l
sleep 2
ls -1 /tmp/*.log | wc -l
check out the tee command to send output to the screen and to an output file.

for the 4th one what regex would search for any singe character ?

Last edited by schneidz; 10-14-2014 at 08:05 PM.
 
Old 10-16-2014, 05:19 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,771
Blog Entries: 1

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
remember that ls -l will have an extra line!

Code:
find /tmp -maxdepth 1 -type f | wc -l
would be better.

Last edited by szboardstretcher; 10-16-2014 at 05:25 PM.
 
Old 10-17-2014, 03:28 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Duplicate thread: http://www.linuxquestions.org/questi...ct-4175522356/
 
Old 10-17-2014, 12:50 PM   #7
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,771
Blog Entries: 1

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Here.

Code:
#!/bin/bash

sleep 2
find /tmp -maxdepth 1 -type f | wc -l | tee project1.data
sleep 2
find /tmp -maxdepth 1 -type f | grep '\.log$' | wc -l | tee -a project1.data
sleep 2
file /tmp/? | wc -l | tee -a project1.data
sleep 2
cat project1.data

Last edited by szboardstretcher; 10-17-2014 at 12:54 PM.
 
Old 10-17-2014, 04:52 PM   #8
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 304

Rep: Reputation: 121Reputation: 121
Quote:
Originally Posted by schneidz View Post
for the 4th one what regex would search for any singe character ?
You gave away the answer there ;-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
School Project - Please Help Moisemark Linux - Hardware 1 02-16-2012 03:31 AM
School project janter Linux - Newbie 17 11-10-2011 10:30 AM
School Project Bovine64 Linux - Networking 2 04-17-2006 07:15 PM
I need a little help for a school project... Tsuroerusu General 25 12-12-2004 08:34 AM
My school project Growly Linux User Groups (LUG) 1 04-30-2004 05:30 PM


All times are GMT -5. The time now is 02:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration