# Fixed Width file using AWK

**URL:** <https://community.unix.com/t/fixed-width-file-using-awk/150918>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [December 21, 2004, 4:35pm UTC](https://community.unix.com/t/fixed-width-file-using-awk/150918 "2004-12-21T16:35:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alok.benjwal](https://community.unix.com/letter_avatar/alok.benjwal/32/6_449c533f586939b6e5f246632a46421f.png) [@alok.benjwal](https://community.unix.com/u/alok.benjwal)\
**Post date:** [December 21, 2004, 4:35pm UTC](https://community.unix.com/t/fixed-width-file-using-awk/150918/1 "2004-12-21T16:35:31Z")

</div>

I am using the following command at the Unix prompt to make my 'infile' into a fixed width file of 100 characters.

awk '{printf "%-100s\n",$0}' infile \> outfile

However, there are some records with a special character "�"

These records are using 3 characters in place of one and my record size is increasing to 102 because of that.

Can someone suggest me a solution so that the width of the record does not exceed 100 when I transfer this file as text to other server using ftp?

Regards,  
Alok

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/6_449c533f586939b6e5f246632a46421f.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [December 22, 2004, 10:32am UTC](https://community.unix.com/t/fixed-width-file-using-awk/150918/2 "2004-12-22T10:32:11Z")

</div>

try something like:

```nohighlight
awk '{printf "%-100s\n", substr($0,1,100 } ' filename

```

---

<div class="post-metadata">

**Author:** ![alok.benjwal](https://community.unix.com/letter_avatar/alok.benjwal/32/6_449c533f586939b6e5f246632a46421f.png) [@alok.benjwal](https://community.unix.com/u/alok.benjwal)\
**Post date:** [December 5, 2005, 10:39am UTC](https://community.unix.com/t/fixed-width-file-using-awk/150918/3 "2005-12-05T10:39:24Z")

</div>

how do i list the usage by user-id in a Unix Filesystem?
