How to create new empty utf8 file for appending?


 
Thread Tools Search this Thread
Operating Systems Linux How to create new empty utf8 file for appending?
# 1  
Old 06-30-2014
How to create new empty utf8 file for appending?

Hey i try to create empty text file with utf-8 encoding
without success
what is the right way to do this ?

tried with
Code:
touch test.txt 
iconv -f UTF-8 -t UTF-8 test.txt


or
Code:
iconv -f latin1 -t UTF-8 test.txt

# 2  
Old 06-30-2014
Try something like this

Code:
iconv -f ascii -t utf-8  inputfile -o outputfile

# 3  
Old 06-30-2014
I don't think you can identify nor create an empty "UTF-8 file".
# 4  
Old 06-30-2014
Code:
touch test.txt

creates an empty file. Until you write data into it, it is an empty ASCII file, an empty EBCDIC file, an empty UTF-8 file, an empty ISO 8859-1 file, an empty ISO 8859-6 file, and an empty file encoded with any other codeset you choose to select.
# 5  
Old 07-01-2014
well i did touch test.txt
and when i do file -bi output_gt/test.txt
im getting :
Code:
application/x-empty; charset=binary

and then i trying to write data in utf8 encoding to it with
$data >> test.txt
and all in gibberish
when i do on the file file -bi output_gt/test.txt:
im getting :
Code:
text/plain; charset=unknown-8bit

what can i do ?
# 6  
Old 07-01-2014
Code:
$data >> test.txt

does not give us sufficient information to determine how you generated the contents of test.txt. Please provide exact details.
# 7  
Old 07-01-2014
ok more info as much as i can
this is part in the script that write into file :
Code:
#set string_to_print = `echo $STRING_CONCAT | awk '{$0=substr($0,1,length($0)-1); print $0}'` 
set string_to_print = `echo $STRING_CONCAT | awk '{gsub(/,$/,""); print}'`
echo $string_to_print>>$new_file_full_path
set STRING_CONCAT=""

now when i keep the second awk ( awk '{gsub(/,$/,""); print}'`)
it prints me gibberish
if i uncomment the first awk ( and comment the second )
the file remains utf-8 but the awk is wrong because in some cases it doesn't remove the last character

i have no idea why the first awk keeps the file utf-8
and the second not .
the text im writing to file is Russian
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need UNIX command to create a empty dataset

Hi all, Is Der any unix command which will create a empty dataset ..?(in .ds ).I know we can use orchadmin dump command to view dataset data.. but how to create a dataset..? like sampledataset.ds thanks in advance hemanthsaikumar (1 Reply)
Discussion started by: hemanthsaikumar
1 Replies

2. Shell Programming and Scripting

Create empty files from a list on file

Hello Guys. Please I would like to create empty files from a list In file1 will be the followin values, so i will like to create for each name a empty file. file1 2191off-r0.sps 2192off-r0.sps 2193off-r0.sps 2194off-r0.sps 2195off-r0.sps So I need to get 5 empty files. Thanks for... (7 Replies)
Discussion started by: jiam912
7 Replies

3. Shell Programming and Scripting

Single command to create multiple empty files(no trailing lines as well).

Hi, i need a single command to create multiple empty files(no trailing lines as well) and empty the files if already existing. please let me know or if this has been ansered, if some ocan share the link please, thanks > newfile.txt or :> newfile.txt do not work (4 Replies)
Discussion started by: Onkar Banerjee
4 Replies

4. UNIX Desktop Questions & Answers

how to create empty wav file

Dear All, Kindly explain me a command in unix to create a empty wav file with example. Thanks in Advance! (1 Reply)
Discussion started by: thillai_selvan
1 Replies

5. Shell Programming and Scripting

Convert to UTF8 File - Unix

All, I have several *.dat files which is created in windows (ANSI Endoing) Or PC File format, once I copy those files to unix. How can I convert those file to utf8 encoding ? I tired iconv, it says not supported Please help Thanks - S (5 Replies)
Discussion started by: Shanks
5 Replies

6. Shell Programming and Scripting

cowardly refusing to create an empty archive

Hi, I am trying to write an Archive script that should look for files older than x days, zip them and move the zip to the archive directory and delete the files that have been zipped. I am not sure how i can handle this error: "cowardly refusing to create an empty archieve". Just wanted to know... (9 Replies)
Discussion started by: stunnerz_84
9 Replies

7. Shell Programming and Scripting

How to replace comma by slash using sed in an UTF8 file

Hello all, I'd like to replace "," by "/" in a utf8 file from postion X to Y. Comma "," is also defined as delimiter. 12345678901234567890,123456789012345,12345678901234567890, aaaa,aaaa,aaaaa ,bbb,bbbb,bbbbb ,cccccc,cc , Result should be... (1 Reply)
Discussion started by: fmofmo
1 Replies

8. Shell Programming and Scripting

Converting Unicode file to UTF8 format

Hi, I have a file in my desktop which is a unicode format. After this file is transferred to Unix using FTP, we are seeing some special character (like rectangle box type) at the first line. The same file is saved as UTF8 (using textpad tool, selecting encode to UTF-8 option) on my desktopand... (7 Replies)
Discussion started by: vfrg
7 Replies

9. UNIX for Dummies Questions & Answers

Getting same exit status for empty and non empty file

Hi All, I am checking for a empty input file to do some further action , but I am getting exit status 0 in both the cases , for empty and non empty file both. The value of $? is coming 0 in if part also and else part too. #!/bin/ksh if ]; then echo "data" # exit 0 echo "$?" else... (4 Replies)
Discussion started by: mavesum
4 Replies

10. Shell Programming and Scripting

simultaneously create three empty files?

I can't get touch to simultaneously create three empty files file1, file2, file3. I tried:$ touch filebut all I got was one file:$ fileWhat did I do wrong? (4 Replies)
Discussion started by: na5m
4 Replies
Login or Register to Ask a Question