It is currently Tue, 17 May 2022 02:10:22 GMT



 
Author Message
 sed truncate end of line

cut -c1-8

sed 's,^\(........\).*,\1'

I think using cut is easier. But maybe I missed a better way to do
it with sed.

tobias



 Sat, 21 Jul 2001 03:00:00 GMT   
 sed truncate end of line

Sure.  Use something like this (I'm not a sed expert, so there's
probably a cleaner way):

sed -e 's/^\(.\{8\}\).*$/\1/' <file

Or use cut:

cut -b1-8 <file

To change the file in place, you can use perl:

perl -i.bak -pe 's/^(.{8}).*/\1/' file

Aaron
--
Aaron Baugher - abaug...@rnet.com - Quincy, IL, USA
Extreme Systems Consulting - http://haruchai.rnet.com/esc/
CGI, Perl, Java, and Linux/Unix Administration



 Sat, 21 Jul 2001 03:00:00 GMT   
 
   [ 4 post ] 

Similar Threads

1. sed expression for truncating line length

2. Newbie: delete end of line with sed

3. sed: appending line to end of file

4. sed insert character in specific position relative to end of line

5. sed: last line is omitted if no \n at the end of file

6. sed and appending data to the end of every line

7. A sed deletion from a character to the end of the line

8. sed end-of-line anchor


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software