Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim first 9 letters using awk, sed

Tags:

shell

sed

awk

I have following data in file, i need to only keep first 9 character of file and | tee it to another file

03755432101JONPORT,
037554321031979123120800000000000000000000000000000000
0375543210413855
03755432105JEEY
03755432111P63
03755432133100620120000008156GR1

should look like

037554321
037554321
037554321
037554321
037554321
037554321
like image 341
Maulzey Avatar asked Oct 01 '12 22:10

Maulzey


1 Answers

For such a simple task, use cut:

cut -b1-9

If your data contains Unicode, you might need -c instead of -b.

like image 174
choroba Avatar answered Sep 28 '22 00:09

choroba