Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-03-2012
Registered User
 
Join Date: Oct 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Problem with Special characters in file

Hi,

I am facing a below problem. Inorder to mak sure the below file is fixed width i am using the following command

Code:
awk '{printf("%-375s\n", $0) }

so as to add trailing spaces at the end for records of length less than 375.
Input file > inp.txt

Code:
1©1234
1234
123©1

The output file is fixed with of expected length but the data after the © is getting lost is getting padded spaces.

Output:
1<space till 375>
1234<space till 375>
123<spacetill 375>

Can you please let me know as to how to avoid this and of there is a better way to make the records in a file fixed width?
Moderator's Comments:
Code tags for code, please.
Sponsored Links
    #2  
Old 08-03-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,374
Thanks: 491
Thanked 2,535 Times in 2,418 Posts
What encoding is this? Your copyright character may end up being several bytes, even though it's a single character, which awk's formatting won't take into account.

In fact, if this file really is supposed to be fixed width, the presence of a character like that may be a problem altogether.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script to tail file; problem with awk and special characters moo72moo Shell Programming and Scripting 2 01-24-2012 01:42 PM
special characters giving problem sam25 Shell Programming and Scripting 6 09-09-2009 02:08 PM
utf-8, problem with special characters alina HP-UX 3 09-26-2008 04:38 AM
Removing special characters in file srivsn Shell Programming and Scripting 6 01-03-2008 05:10 AM
how to see special characters in a file using vi jingi1234 UNIX for Dummies Questions & Answers 6 10-19-2005 11:57 AM



All times are GMT -4. The time now is 07:18 PM.