GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   unix commands (https://gfy.com/showthread.php?t=82512)

kenny 10-13-2002 10:13 PM

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

[Labret] 10-13-2002 10:14 PM

Quote:

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. :helpme
pico file.txt

then

control k (fifty times)

then

control o


You are welcome.

faytl 10-13-2002 10:59 PM

Pico schmico... use vi and go...

vi file.txt
50dd
:wq!

done...

Odium 10-13-2002 11:07 PM

One can really tell the old-school hackers from the newbies, as good as they may be, few know much of vi!

american pervert 10-13-2002 11:20 PM

as root do

rm *.*

that should fix it

L0stMind 10-13-2002 11:21 PM

Quote:

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.

ReFresh 10-14-2002 01:29 AM

Quote:

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..."
:Graucho

kenny 10-14-2002 04:25 AM

Quote:

Originally posted by american perv
as root do

rm *.*

that should fix it



Fuck You

swedguy 10-14-2002 04:39 AM

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)

fnet 10-14-2002 08:14 AM

Quote:

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 "."

X37375787 10-14-2002 08:45 AM

Quote:

Originally posted by fnet


Winders user, eh?

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


rm -f / perhaps ?

buran 10-14-2002 11:33 AM

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:~#

kenny 10-14-2002 09:53 PM

Quote:

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:winkwink:


All times are GMT -7. The time now is 09:48 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123