Find the answer to your Linux question:
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 34
Alright thanks, I think I've got it now. So the final code should therefore be: #!/bin/sh ls > Files echo "wc -l" ....I think?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23

    Alright thanks, I think I've got it now.

    So the final code should therefore be:

    #!/bin/sh
    ls > Files
    echo "wc -l"



    ....I think?

  2. #12
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    Quote Originally Posted by Scarfinger
    Alright thanks, I think I've got it now.

    So the final code should therefore be:

    #!/bin/sh
    ls > Files
    echo "wc -l"



    ....I think?
    Your almost there, just the last line need to be looked at.
    Code:
    echo "wc -l
    if you do that at a shell prompt you'll get this return:
    Code:
    wc -l
    < You want to want to print the output of wc -l not "wc -l" itself, so from this what do you deduce?

    >The use of "echo" is wrong...which comand in the shell will print the contents of a file? Since this is what has to be done. And remember I said to look up pipes? You'll have to use your knowlage of pipes to get the output of the printing of Files to be parsed through wc -l, so that you'll get the output for wc -l.
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  3. #13
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    Oh dang..

    Bear with me on that one.

  4. #14
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    The only way of printing text on the screen that I know of is the "echo" function

    Presumably though once I know what this other printing function is, (besides echo), i'd just do:

    #!/bin/sh
    ls > Files
    (insert new printing function) | wc -l



    I think

  5. #15
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    What you have is fine (once you have the other command )

    Look at this manpage: http://www.linuxcommand.org/man_pages/cat1.html it should help you print the contents of the file...
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  6. #16
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    !!!!!!!!!!!!!!!!!!!!!


    #!/bin/sh
    ls > Files
    -n | wc -l


    !!!!!!!!!!!!!!!!!!!!!!


    Right. ...right?

  7. #17
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    Quote Originally Posted by Scarfinger
    !!!!!!!!!!!!!!!!!!!!!


    Code:
    #!/bin/sh 
    ls > Files 
    -n | wc -l

    !!!!!!!!!!!!!!!!!!!!!!


    Right. ...right?
    Quote Originally Posted by cat man page
    cat - concatenate files and print on the standard output
    Read that ^^. What's it saying? It's saying "print the contents of a file". Now look at your script...does your script do this? Look carefully...does it use cat at all?

    Quote Originally Posted by cat man page
    cat [OPTION] [FILE]
    okay from that we'll say that cat may need an option and may need a file. But all I want it to do is print the contents of the file...so do I need options? Secondly it says you can use a file to read....and in your case which file would this be?

    sorry for being a bit roundabout about this...but you need to learn something from this.
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  8. #18
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    ARGHHHH

    oh, right, i understand.

    It needs to be:


    #!/bin/sh
    ls > Files
    cat -n | wc -l




    [Please sweet jesus let this be right]

  9. #19
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    Quote Originally Posted by Scarfinger
    Code:
    #!/bin/sh 
    ls > Files 
    cat -n | wc -l
    [Please sweet jesus let this be right]
    Almost!

    You have the right idea now, you just have to have cat reading File. And also you don't need any options...(other than the file).
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  10. #20
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    #!/bin/sh
    ls > Files
    cat -n | wc -l


    cat reading the file, cat reading the file..
    I think I'm lost.


    #!/bin/sh
    ls > Files
    cat -n < File
    cat -n | wc -l ?? <----- That's surely not right...



    My brain is melting.

Page 2 of 4 FirstFirst 1 2 3 4 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •