-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 What is the correct syntax for sed to delete the last 10 lines of a file? I am writing a script that extracts source html from a website; and then constructs news bites for the Postnuke CMS. And then performs the neccessary mySQL commands to insert them into the database. I have removed the neccessary tags prior to the news bites ------- but removing the post tags evades me. As always, thanks for your help. - -- Thomas Jones Linux-Howtos Network Administrator OpenGPG Key: 0x6A3DF6E9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQE/fvs/QT2komo99ukRArZUAKCwvZK6/noC0lBb2a6Bfug3gNDbWwCg6wts tKMuiCPYRXTi0W3CMUygg50= =SLXW -----END PGP SIGNATURE-----
* Thomas Jones (thomas.jones@linux-howtos.com) [031004 09:46]:
What is the correct syntax for sed to delete the last 10 lines of a file?
You would need to know to know how many records are in the input to do that with sed. E.g., sed -e '$-10,$d' won't work since $ is defined until the EOF. You'll have to use awk for that. -- -ckm
-----Original Message-----
From: Christopher Mahmood
* Thomas Jones (thomas.jones@linux-howtos.com) [031004 09:46]:
What is the correct syntax for sed to delete the last 10 lines of a file?
You would need to know to know how many records are in the input to do that with sed. E.g., sed -e '$-10,$d' won't work since $ is defined until the EOF. You'll have to use awk for that.
--
You could use wc in conjuction with sed. wc -l will return the number of lines in a text file. Ken
* Ken Schneider (kschneider@rtsx.com) [031004 13:52]:
You could use wc in conjuction with sed. wc -l will return the number of lines in a text file.
Well, it returns the number of new line characters which, since this is html, may or may not be the same thing. Just one of the many that reasons that trying to parse html with regexes doesn't work very well. -- -ckm
participants (3)
-
Christopher Mahmood
-
Ken Schneider
-
Thomas Jones