Find the answer to your Linux question:
Results 1 to 3 of 3
Hello All, I have a large file, lets say test.bak, that has over 5000 lines of text (over 100k of text). I need to come up with some sort of ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    1

    Script for Moving Text

    Hello All,

    I have a large file, lets say test.bak, that has over 5000 lines of text (over 100k of text). I need to come up with some sort of script to move the first 30k of data into a seperate file (test.mmddyyyy). The text must be taken out of test.bak when moved to test.mmddyyyy.

    This is for an assignment, and I want to learn this stuff, so please do post any solutions. Any suggestions or hints on where to go from where I am right now? This may not even be a good start...

    #!/bin/bash
    n=`ls -l test.bak | awk`{print $5}'' (for finding the file size)

    if [ n &gt 30000 ]
    then

    ????

    I think I may need the mv command, but dont know where to go now. Thanks !

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    The forum rules do not allow anyone to post a solution to a homework question, for the record.

    Having said that, do you honestly have no idea about what you are going to do? So far, you have written a check to determine whether the file is > 30 KB, and haven't explained any of your thoughts on actually doing this process.

    Most of us would be happy to take a look at an algorithm you provide, and we can answer specific questions, but you have given us absolutely nothing as yet.
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Linux Newbie
    Join Date
    Jan 2008
    Location
    UK
    Posts
    211
    Perhaps set a buffer to the size you want, that you can set when doing the copying / transfer. And then direct it to the file.
    Depends on what you want it written in as well.

Posting Permissions

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