LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Having trouble with my linux homework (https://www.linuxquestions.org/questions/linux-newbie-8/having-trouble-with-my-linux-homework-4175477134/)

ruthmom1979 09-14-2013 01:15 PM

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.

John VV 09-14-2013 01:54 PM

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

fogpipe 09-14-2013 03:53 PM

never mind misread the op

John VV 09-14-2013 04:27 PM

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

PTrenholme 09-14-2013 05:54 PM

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>

jamison20000e 09-14-2013 09:24 PM

Cheater. :eek: :)

ruthmom1979 09-15-2013 05:45 AM

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.

jamison20000e 09-15-2013 07:50 AM

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... :hattip:

ruthmom1979 09-15-2013 10:52 AM

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?

jamison20000e 09-15-2013 11:06 AM

Quote:

Originally Posted by ruthmom1979 (Post 5028013)
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! :)

ruthmom1979 09-15-2013 11:16 AM

Quote:

Originally Posted by jamison20000e (Post 5028019)
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.

jamison20000e 09-15-2013 11:32 AM

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! :banghead:


All times are GMT -5. The time now is 06:37 AM.