LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-10-2007, 07:02 AM   #1
elektronaut
LQ Newbie
 
Registered: Nov 2006
Distribution: Ubuntu Edgy
Posts: 12

Rep: Reputation: 0
Shell command for adding a byte to a file


Hi,

I'm trying to use my digital audio player with Linux. The playlists have to be in UTF-16 format with byte order mark (BOM). With the help of unix2dos and iconv I managed to convert them from UTF-8 to UTF-16 with the Windows line breaks (CR & LF). It works if I add the BOM with a hex editor, but I'm looking for a shell command so that I can put it all together in script in order to automate the process. It would have to be able to add a byte at the beginning of a binary file. I've been googling for this for quite some time now, can somebody help me out, please?
 
Old 06-10-2007, 07:18 AM   #2
stzein
Member
 
Registered: Mar 2004
Location: Antwerp, Belgium
Distribution: Gentoo
Posts: 65

Rep: Reputation: 15
Maybe you can make 2 files. The existing playlist file and a 1 byte file. Then do something like this:
Code:
cat 1byte.file > finalplaylist.file && cat playlist.file >> finalplaylist.file
I'm not sure if this works at all for your purpose as it may very well mess up your format again, but at least it's easy to try.

Here's the manual of the GNU coreutils, maybe there's something in there that can be of use to you (tr for example might be of use for the translation part, although you seem to have a solution for that already)

Last edited by stzein; 06-10-2007 at 07:30 AM.
 
Old 06-11-2007, 06:02 AM   #3
elektronaut
LQ Newbie
 
Registered: Nov 2006
Distribution: Ubuntu Edgy
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks, stzein,

that was a good idea. As cat doesn't append, I'm now using this combination:
Code:
cat 1byte.file > finalplaylist.file && dd if=playlist.file of=finalplaylist.file oflag=append conv=notrunc
I'm happy that I got a working solution, but if there is a way that would make the 1byte.file obsolete, I would still be happy to know it. Then a bash script alone could do the job.
 
  


Reply

Tags
bash



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell command to remove all .exe file limit_me Linux - Newbie 2 05-29-2007 11:12 PM
command or shell script to print line range from file minil Programming 3 12-28-2005 08:05 AM
Script File: Parsing command sent to shell cheema Programming 1 07-01-2005 12:54 PM
Linux shell command for makefile.in to create a text file and write to it alix123 Programming 8 01-07-2005 08:18 AM
execute shell command inside of tcl file khucinx Programming 1 07-05-2004 01:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration