Posts

Showing posts with the label text edit

Delete lines based on a length limit

The following command deletes lines which have less than 10 characters. sed '/.\{10\}/!d'

Remove the First N Characters From a Line

The following codes remove first 6 characters. Change the number accordingly... cut -c7- ' this works rr ^.{6} ' rr was not installed colrm 1 6 rr s/^.{6}// sed's/^.\{6\}//' perl -pe's/^.{6}//' ruby -pe'sub /^.{6}/,""' gawk'BEGIN{FIELDWIDTHS="6 999"}{print$2}'

How to clear trailing spaces using VIM

:%s=\s\+$== And thats it! The % tells it to be global - not just the current line. s is a shortcut for substitute. The \s (whitespace) and \+ (at least once) are regular expression terms (the + needs to be escaped, it seems…). The $ (dollar) represents the end of a line. The = are being used as delimiters, the == at the end implies that the pattern is replaced with nothing.