Find the answer to your Linux question:
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 34
look at the syntax in the man page: Code: cat [FILE] where you replace [FILE] with the file you read... (btw you don't need the -n with the cat). in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #21
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157

    look at the syntax in the man page:
    Code:
    cat [FILE]
    where you replace [FILE] with the file you read... (btw you don't need the -n with the cat).

    in the end the cat [FILE] will be on the same line as | wc -l

    dylunio
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

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

    !

  3. #23
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    WOOOHOOO!!!!

    you got it:
    Code:
    #!/bin/sh
    ls > Files
    cat Files | wc -l
    There may not be other times when I'm bored, so get yourself some kind of system where you can test if these scripts work at all.
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  4. $spacer_open
    $spacer_close
  5. #24
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    Eurika!


    At long last, ey.

    Great, thanks enormously.

  6. #25
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    Hm... Pardon me, but I've arrived at a SECOND blip..

    I think it's quite a simple problem though.

    I'm trying to move all .txt files from my current directory to one called TxtFiles.

    I think that to do this I can use:

    #!/bin/sh
    *.txt > TxtFiles

    Does that seem right? I don't have access to Linux so I'm unable to test it.

    Now though, what I want to do is produce a text file that then displays the list of .txt documents that were moved. This text file could be called something like "txtFilesMoved".

    Any clues on how I would go about this? I aren't too sure where to even start when it comes to listing moved files. I feel the possible need for a pipe..


    thanks.

  7. #26
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    This is more complicated...if you want to move all the .txt files from one place to another but with changed names, then list them you'll have to look into such things as for loops (google them, as well as look at www.linuxcommand.org), and variables.
    Also look into the cp or mv for changing the location of the files.
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  8. #27
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    Oh okay thanks, I don't need to change the individual .txt file names though. I just want to move them to a different directory named TxtFiles.


    Using the mv command, would this work then for moving the .txt files from the current directory all to a TxtFiles current directory? :

    #!/bin/sh
    mv *.txt --target-directory=TxtFiles

  9. #28
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    Quote Originally Posted by Scarfinger
    Using the mv command, would this work then for moving the .txt files from the current directory all to a TxtFiles current directory? :

    Code:
    #!/bin/sh 
    mv *.txt  --target-directory=TxtFiles
    You don't need teh --target-directory= stuff just have it
    Code:
    mv *.txt TxtFiles
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  10. #29
    Just Joined!
    Join Date
    Oct 2005
    Posts
    23
    Okay great, got it.


    So now after managing to move all these files, I need a .txt file that displays the full list of text files that were moved.


    I think I'll need the ls command for that.

    Do you think something as simple as this would work? :

    ls > TxtFilesMoved

    Would that produce a text file containing all of the text files I've moved from the current directory into TxtFiles?

  11. #30
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    It would work if you used ls in conjunction with the naming of the directory if was to list.

    You realy REALY need to ether get Linux installed or install Cygwin...otherwise your going to have a hell of a time.
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

Page 3 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
  •