![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Removing last character from each line of file | cjhancock | Shell Programming and Scripting | 17 | 08-29-2008 05:05 AM |
| Removing text from a line in a file | outthere_3 | Shell Programming and Scripting | 10 | 02-13-2008 03:38 AM |
| removing a character and addending to end in each line in a file | arunkumar_mca | UNIX for Dummies Questions & Answers | 5 | 01-30-2008 12:48 AM |
| Removing a particular line from a text file | sendhilmani123 | Shell Programming and Scripting | 5 | 05-31-2006 09:32 AM |
| perl question - removing line from input file | reggiej | Shell Programming and Scripting | 3 | 06-07-2005 02:45 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi, I searched the forums but could not find anything that was very useful. I am trying to remove the very last line from a file and display the rest of the file.
Is there a way to use cut and tail together? Any other suggestions? Thanks |
|
||||
|
what do you want???
1. to just display $ sed '$d' your_infile_name 2. to save the changes to a new file $ sed '$d' <your_input_filename >new_output_filename were the new_output_filename will be created once the command got executed. instead of your_input_filename provide your source filename and instead of output_filename just give some name. once after executed a new file will be created without the last line from your input_filename. |
|
||||
|
I ran that command Code:
sed '$d' OLD_FILE > NEW_FILE and it just displays the OLD_FILE contents. In other words I want to display everything up to the last line of the OLD_FILE but I don't know how many lines there are in the file, it changes everyday. |
|
||||
|
that's ok,
can you check the old and the new files. old file will contain all the lines. new file will contain 1 line minus than the old. So, your correct output will be in NEW_FILE. Note: no issue with the no of line in the files. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|