Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vi keep only first 10 characters of a column

Tags:

vim

sed

awk

how do i do this in vi?

awk -F"," awk '{print substr($1,1,10)}'

I only want to keep the first 10 characters of my date column (example 2014-01-01) and not include the timestamp.

I tried to do it in awk but i got this error:

sed: RE error: illegal byte sequence

I believe it is a bash_profile setting error.

This is what i have in my bash_profile:

#export LANG=en_US.UTF-8
#export LOCALE=UTF-8

export LC_CTYPE=C
export LANG=C
like image 645
jxn Avatar asked Nov 17 '15 08:11

jxn


1 Answers

in vim, do:

:%norm! 11|D

this will affect all lines in your buffer.

If you like, :s could do this job too.

like image 148
Kent Avatar answered Sep 19 '22 20:09

Kent