![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Delete line in text file | Berserk | UNIX for Dummies Questions & Answers | 6 | 12-16-2008 03:44 PM |
| How to delete a particular text without opening the file. | stevefox | Shell Programming and Scripting | 12 | 02-21-2008 01:24 PM |
| Delete first line from any text file ? | aungomarin | Shell Programming and Scripting | 5 | 05-16-2006 10:42 PM |
| how to delete away text in a file? | forevercalz | Shell Programming and Scripting | 5 | 01-08-2006 10:28 PM |
| delete last line from text file | hcclnoodles | Shell Programming and Scripting | 4 | 06-25-2002 10:52 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Overwrite & Delete in Text File
Dear All,
I have text file like this: Header Record 1 Record 2 ....... Record n Tail This line of code : awk '{ if ( NR == 1 ) { head=substr($0,1,300);} else { last = substr($0,1,300);}END{printf "Header is : %-300s Trailer is : %-300s\n", head, last}' filename converted Header and Trailer in one line and within 300 character each.The output is just one line. Now I want to overwrite this one line above (Header+ Tail) over the first line of original file (orginal header) and delete the Tail........i can copy this header and tail to new file and then append Record 1 to Record n to this new file, but that will cause too low performance........so I think better to update first and the last line of the this file.................so how can i do that? i.e. 1-update the header with new line i.e. (header+trailer) 2-delete the tail in original file (may be using cut tail -1 filename?) |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|