Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using this script i am deleting last three lines from a file
Here in this case, my script and the file in which the lines to be deleted are in the same location.
so simply run
./script or sh -x script
so that last three lines from filename called file would be deleted.
Note : the filename is mentioned in the script itself, if your file is in someother location just edit the script as
"sed -i '$d' path_to_the_file_whose_lines_to_be_deleted" and run the script.
Posted 12-31-2013 at 01:22 AM bydinakumar12 Updated 12-31-2013 at 01:27 AM bydinakumar12
how to using the script,
It's getting parameter or have to defile file path in script, or what else?
I think, you have to give a sample to understandable.
for example,
should write command like following to delete last 3 lines of file.txt
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.