Cut a fixed width in the File

May 18, 2011 at 05:12:44
Specs: Windows XP
Hi,

I am below cut command:


cat test.txt | cut -c 1-320 > test_final.txt

This will cut till 320 width of each line. But i am not able to cut, if a line include an special characters(such as Ü,ç,ò,etc).

Please Help on this

Thanks
Umar


See More: Cut a fixed width in the File

Report •

#1
May 18, 2011 at 18:32:01
I didn't test this, but in your shell, try setting noglob

#!/bin/ksh

set noglob

cat test.txt | cut -c 1-320 > test_final.txt

The Korn shell in cygwin cuts the characters without any problems.

If those characters you posted are out of your data file, then you have a NULL character in your string. You'll need to convert them to a space in order to solve your problem.


Report •
Related Solutions


Ask Question