LinuxQuestions.org
Review your favorite Linux distribution.
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 09-14-2013, 02:15 PM   #1
ruthmom1979
LQ Newbie
 
Registered: Sep 2013
Posts: 4

Rep: Reputation: Disabled
Having trouble with my linux homework


I am taking Liunx Fundamentals to learn Linux. I am having trouble with 2 questions in an assignment. Attached is a text file of the classic Sherlock Holmes story, The Speckled Band. Complete the following steps.

1. Find how many times the word band is used in story (using command line tools, no graphical methods).
2. Number the lines in the story so that the numbered lines are saved

I thought maybe grep for the first one but it only counted band in each line, not multiple instances in a line. I know how to number the lines but it's the saved part that's throwing me off. Any help appreciated.
 
Old 09-14-2013, 02:54 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,239

Rep: Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527
for 1
have a look at "cat" and "grep"

the same for 2

and write a shell script
http://www.tldp.org/LDP/abs/html/
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
 
Old 09-14-2013, 04:53 PM   #3
fogpipe
Member
 
Registered: Mar 2011
Distribution: Slackware 64 -current,
Posts: 550

Rep: Reputation: 194Reputation: 194
never mind misread the op

Last edited by fogpipe; 09-14-2013 at 05:04 PM.
 
Old 09-14-2013, 05:27 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,239

Rep: Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527Reputation: 2527
aslo for
Quote:
2. Number the lines in the story so that the numbered lines are saved
the lines or sentences ???

the number of lines is dependent on the Number of characters in YOUR terminal
( seeing as you can NOT use a gui )
the lines in VI will change on how wide the terminal is
 
Old 09-14-2013, 06:54 PM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
For question 2, look at the nl command, e.g. man nl.

For question 1, consider using the -o option of grep and piping the output into wc with the appropriate option. Something like grep -io band <file> | wc <option>
 
Old 09-14-2013, 10:24 PM   #6
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth( I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,663
Blog Entries: 2

Rep: Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123
Cheater.
 
Old 09-15-2013, 06:45 AM   #7
ruthmom1979
LQ Newbie
 
Registered: Sep 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
I would like to thank everyone who gave useful hints that helped point me in the right direction. To the person who called me a cheater, asking for help on a new concept you don't understand is NOT cheating. Cheating is getting the answer with no work involved. If you can't contribute something useful don't bother contributing anything at all.
 
Old 09-15-2013, 08:50 AM   #8
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth( I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,663
Blog Entries: 2

Rep: Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123
Sorry if you misunderstood the smiley face (And\or, didn't like the text? I love #6+) but people were smart enough to NOT outright give the answers you asked for...

Last edited by jamison20000e; 09-15-2013 at 09:12 AM.
 
Old 09-15-2013, 11:52 AM   #9
ruthmom1979
LQ Newbie
 
Registered: Sep 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Really? Linking study tips for dummies not meant to be insulting? What planet are you from? Plus never asked for answers asked for any help appreciated. And what I meant by that is I'm lost, this is what I did, throw me in the right direction. Which is what most people did. I stand by post if you're not going to post a useful reply then why bother posting?
 
Old 09-15-2013, 12:06 PM   #10
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth( I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,663
Blog Entries: 2

Rep: Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123
Quote:
Originally Posted by ruthmom1979 View Post
Really? Linking study tips for dummies not meant to be insulting? What planet are you from? ...
Sorry you feel that way. Your missing very useful info by not looking into the "Dummies" series for smart people! For the record, when I started school that document was the first best help I found it's also the fith link on my blog... there, is also my statement: There are infinite ways to look at anything we can only comprehend "our" own—Get Over It!

Last edited by jamison20000e; 09-15-2013 at 12:09 PM.
 
Old 09-15-2013, 12:16 PM   #11
ruthmom1979
LQ Newbie
 
Registered: Sep 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jamison20000e View Post
Sorry you feel that way. Your missing very useful info by not looking into the "Dummies" series for smart people! For the record, when I started school that document was the first best help I found it's also the fith link on my blog... there, is also my statement: There are infinite ways to look at anything we can only comprehend "our" own—Get Over It!
Never said the Dummies series wasn't useful. You were the one making the assumption that was the "help" I needed. What I think is best is that you don't reply to any of my post and go back to self important world and troll someone else's posts.
 
Old 09-15-2013, 12:32 PM   #12
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth( I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,663
Blog Entries: 2

Rep: Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123Reputation: 1123
No. You think I was trying to insult (instead of tease) you by not (looking past the title) seeing the big picture, of which I clarified\apologized; making you the one under the bridge now... Get Over It!

Last edited by jamison20000e; 09-15-2013 at 12:53 PM.
 
  


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



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:44 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