Problem with Special characters in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with Special characters in file
# 1  
Old 08-03-2012
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:
Mod Comment Code tags for code, please.
# 2  
Old 08-03-2012
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing a file containing special characters

I want to parse a file containing special characters, below is a sample content of file content of file : Serial_no:1$$@#first_name:Rahane$$@last_name:Ajiyenke@@#profession:cricketer!@#*&^ Serial_no:1$$@#first_name:Rahane$$@last_name:Ajiyenke@@#profession:cricketer!@#*&^... (3 Replies)
Discussion started by: rajMjar
3 Replies

2. Shell Programming and Scripting

Substitute special Characters into a file

Hi experts :) I need to replace special characters into a file , in the followiing way : " --> "" ' --> '' _--> \_ I tried with the sed command but I'm getting and error ksh: $: not found. ksh: $: not found. sed: Function s/\/\/ cannot be parsed. Any idea ? Thanks , KOLAS... (2 Replies)
Discussion started by: Kolas79
2 Replies

3. Shell Programming and Scripting

File containing special characters

Hello All, I am facing challenges in order to transfer a file from windows to unix box,the file contains a special character '×' ,now when I am transferring the file from windows to unix that special character converted to something else like 'Ã' ,another thing I have noticed that the hardware is... (1 Reply)
Discussion started by: prarat
1 Replies

4. Shell Programming and Scripting

Problem with special characters....

grep -i "$line,$opline" COMBO_JUNK|awk -F, ' { C4+=$4 } { } END { print C4 } ' OFS=,` when i run this command in the script.... it o/p all the value as 0 if $line contains any special parameters..... but the same script if i run in command prompt... it shows... (4 Replies)
Discussion started by: nikhil jain
4 Replies

5. Shell Programming and Scripting

script to tail file; problem with awk and special characters

Trying to use code that I found to send only new lines out of a log file by doing: while :; do temp=$(tail -1 logfile.out) awk "/$last/{p=1}p" logfile.out #pipe this to log analyzer program last="$temp" sleep 10 done Script works fine when logfile is basic text, but when it contains... (2 Replies)
Discussion started by: moo72moo
2 Replies

6. Shell Programming and Scripting

special characters giving problem

Hi All, I have a CSV file in which some fields contains special character for ex:- my file is file 1 cat file1 abcd,bgfht,ngbht,abvc **** hdlld,hsgdt,bhfy,knht **** whenever i am trying to put a 4th feild in a variable its giving me list of all the files i have in current... (6 Replies)
Discussion started by: sam25
6 Replies

7. HP-UX

utf-8, problem with special characters

Hi all, We are facing the following problem in our HP-UX machine: software that manipulates utf-8 encoded strings (e.g. during string cut), fails to correctly manipulate strings (all containing Greek characters) that contain special characters like @, &, # etc. Actually, in different... (3 Replies)
Discussion started by: alina
3 Replies

8. Shell Programming and Scripting

escaping special characters in file name...

dear, I would like to rename files in a dir to another format, so I write a bash shell script to handle it. But my problem now is how to handle files having special characters like spaces, (, ): "a b c (d).doc" It seems that I need to escape those characters before applying the "mv" command.... (1 Reply)
Discussion started by: lau0001
1 Replies

9. UNIX for Dummies Questions & Answers

How to delete a file with special characters

I don't now exactly how I did it, but I created a file named " -C " cexdi:/home1 $ls -lt total 1801336 -rw------- 1 cexdi ced-group 922275840 23 mars 10:03 -C How do I delete this file ? cexdi:/home1 $rm -C rm: invalid option -- C Syntax : rm filename ... Doesn't work...... (5 Replies)
Discussion started by: yveslagace
5 Replies

10. UNIX for Dummies Questions & Answers

how to see special characters in a file using vi

Hi, I have a file which has special characters. I can't see them when I "vi" the file. But I am sure there are some special un seen characters. How can I see them? Please help. Thx (6 Replies)
Discussion started by: jingi1234
6 Replies
Login or Register to Ask a Question