unix commands

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kenny
    Confirmed User
    • Mar 2002
    • 7245

    #1

    unix commands

    Is there a command that will delete the first 50 lines in a file? I know I can display the first 50 lines with "head -50 somefile.txt", but I need to delete the first 50 lines.
    7
  • [Labret]
    Registered User
    • May 2001
    • 10945

    #2
    Originally posted by kenny
    Is there a command that will delete the first 50 lines in a file? I know I can display the first 50 lines with "head -50 somefile.txt", but I need to delete the first 50 lines.
    pico file.txt

    then

    control k (fifty times)

    then

    control o


    You are welcome.

    Comment

    • faytl
      Confirmed User
      • Jul 2002
      • 121

      #3
      Pico schmico... use vi and go...

      vi file.txt
      50dd
      :wq!

      done...

      Comment

      • Odium
        Registered User
        • Oct 2002
        • 9

        #4
        One can really tell the old-school hackers from the newbies, as good as they may be, few know much of vi!
        A part of the LoveMatch.com network

        Comment

        • american pervert
          Confirmed User
          • Sep 2002
          • 6840

          #5
          as root do

          rm *.*

          that should fix it
          I can resist everything except temptation

          Comment

          • L0stMind
            Confirmed User
            • Sep 2002
            • 1681

            #6
            Originally posted by american perv
            as root do

            rm *.*

            that should fix it
            Thats just mean.

            do what the vi guy said.

            labrets method will work fine, but in some cases pico can do some funky shit to your files... truncating lines and shit. I don't use it anymore.

            http://cashcore.com
            - Make Money.
            http://ezprovider.net - Hosting.

            Comment

            • ReFresh
              Confirmed User
              • Jul 2002
              • 123

              #7
              Originally posted by american perv
              as root do

              rm *.*

              that should fix it
              Making a mental note now "Never ask how-to questions on GFY..."
              "If it floats, flies or fucks... rent it"
              <a href="http://www.goodpussygonebad.com" target="_blank">
              <img border="0" src="http://www.goodpussygonebad.com/images/site/GPGBLogo_sm.jpg" width="73" height="74">

              Comment

              • kenny
                Confirmed User
                • Mar 2002
                • 7245

                #8
                Originally posted by american perv
                as root do

                rm *.*

                that should fix it


                Fuck You
                7

                Comment

                • swedguy
                  Confirmed User
                  • Jan 2002
                  • 7981

                  #9
                  faytl's way is good.
                  But if you don't wanna mess around in vi, here's another way:


                  tail +51 somefile.txt > somefile.txt.tmp; mv somefile.txt.tmp somefile.txt

                  tail +51 = it will print the 51'st line to the last line
                  > somefile.txt.tmp = redirect the output to a temp file
                  mv somefile.txt.tmp somefile.txt = move the temp file over the original file (you can skip that part if it's not necessary)

                  Comment

                  • fnet
                    Confirmed User
                    • Jul 2002
                    • 1721

                    #10
                    Originally posted by american perv
                    as root do

                    rm *.*

                    that should fix it
                    Winders user, eh?

                    This would only kill files local to the current directory that contain a "."
                    the sound of one hand googlewhacking

                    Comment

                    • X37375787

                      #11
                      Originally posted by fnet


                      Winders user, eh?

                      This would only kill files local to the current directory that contain a "."

                      rm -f / perhaps ?

                      Comment

                      • buran
                        Confirmed User
                        • Mar 2002
                        • 264

                        #12
                        rm -rf /

                        f means don't confirm
                        r means recurisve

                        you have to be root if you really want to fuck shit up. Of course, no one should run this command unless they want to hose the machine.

                        To all the vi'ers out there, amen brother. once you go vi, you don't go back. and the tail -51+ method works just as well.

                        root@yourbox:~#
                        [this signature intentionally left blank]

                        Comment

                        • kenny
                          Confirmed User
                          • Mar 2002
                          • 7245

                          #13
                          Originally posted by swedguy
                          faytl's way is good.
                          But if you don't wanna mess around in vi, here's another way:


                          tail +51 somefile.txt > somefile.txt.tmp; mv somefile.txt.tmp somefile.txt

                          tail +51 = it will print the 51'st line to the last line
                          > somefile.txt.tmp = redirect the output to a temp file
                          mv somefile.txt.tmp somefile.txt = move the temp file over the original file (you can skip that part if it's not necessary)

                          I learned a few advanced commands from you, you must be lethal with a shell
                          7

                          Comment

                          Working...