LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-29-2014, 08:38 PM   #1
underground021
LQ Newbie
 
Registered: Apr 2014
Posts: 2

Rep: Reputation: Disabled
Need help to solve this question sh file


The file input contains 10 lines. Each line contains a single word. The file data contains a text document.
Write a script (call it q4.sh). This script takes two arguments. Argument 1 specifies the name of the file containing the text document and argument 2 specifies the name of the file that contains the word list.
When called with valid arguments (both files exist) the script that reads the file input one line at a time and then searches the file data to count the number of occurrences of each of the words contained in input. Make sure your script checks for 1) the existence of the data file and 2) the input file and 3) that there are at least 2 command lines parameters provided to your script.
Your output should contain look something like the following with the information customized to your account and host:
User: username
Host: hostname
Word: 1st word Count: ###
Word: 2nd word Count: ###
etc. until all ten words have been completed.
Your script should provide a help message if the wrong number of parameters is provided or if one or both of the files is missing.
When you complete your script:
1) Run the script c4.sh, it will create a file called q4.txt.
 
Old 04-29-2014, 09:14 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,679

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Welcome to LinuxQuestions.

Quote:
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
Now, where are you having problems? Post any code you have already written.
 
Old 04-29-2014, 09:22 PM   #3
underground021
LQ Newbie
 
Registered: Apr 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
I don't understand at all about this question. Can you give me some resources what should I look for?
 
Old 04-29-2014, 10:11 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,679

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Lets start at the beginning.

Have you learned anything about command line arguments?

http://www.tldp.org/LDP/abs/html/
 
Old 04-30-2014, 05:45 AM   #5
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 04-30-2014, 07:50 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by underground021 View Post
I don't understand at all about this question. Can you give me some resources what should I look for?
How about you at least start by trying to write the start of a script and posting that.

For example you're supposed to check the arguments passed to the script and if those are not correct, you output an error statement showing the proper usage for the script.

Instead of going as far as checking out arguments, how about you write a script which just prints out that usage line and exits.

Then post that within [code][/code] tags.

In other words, write a script which prints out one line, and exits.

If you can't, or won't even do that, then try reviewing the resource shown to you by michaelk, that is the definitive shell script guide IMHO.

You have to start somewhere and you've not shown that you've even tried.
 
Old 04-30-2014, 01:33 PM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Others have provided good feedback, but it does still amuse me that teachers have the gall to ask questions about things that have never been taught. Surely a good teacher would
give you at least a rudimentary understanding of a subject before asking about something that the course should have taught you ... sheesh
 
  


Reply



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
SOLVE this RHCSA EXAM Question shejin983 Linux - Newbie 3 11-29-2012 03:46 AM
how to solve this question if i face it in interview ahmooody Linux - Newbie 1 03-13-2012 03:47 AM
how to solve this question if i face it in RHCSA EXAM ahmooody Linux - Newbie 1 03-13-2012 03:34 AM
can anyone help me solve this question by giving me the solution?? please~~~ thx anzdyy Programming 9 09-09-2007 03:55 AM
who can help me solve the following question? KoRiR Linux - Networking 1 04-28-2004 03:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:16 AM.

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
Open Source Consulting | Domain Registration