LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 09-15-2004, 03:05 PM   #1
aurelio26
Member
 
Registered: Dec 2003
Location: CANADA
Distribution: Fedora
Posts: 40

Rep: Reputation: 15
SED - Converting UNIX to DOS file


Hi There,

I am new to Linux so forgive me if I ask something silly!
I have a problem with file contaning data that should be loaded to Palm device.

This few lines are example of original barcode_temp.txt file unloaded from Linux 6.2 and Informix database.

Just to mention that if I create same file from Windows environment file can easily be loaded into Palm. But we want to automate whole process because it is way easier to use bash script and cron to finish job.

056595521000,CT MAYONNAISE,3.69,4009,0.00,
056595521109,CT WHIPPED SALAD DRESSING,3.39,4010,0.00,
056595450003,CT MUSTARD SQUEEZE,1.59,4044,0.00,
056595425001,CT MUSTARD SQUEEZE,1.09,4045,0.00,
056595437516,CT DIJON MUSTARD,1.79,4046,0.00,
056595437523,CT MAYO DIJON MUSTARD,1.79,4047,0.00,
056595437530,CT HONEY MUSTARD,1.79,4048,0.00,
056595475006,CT MUSTARD JAR,1.59,4049,0.00,


I did

sed -e 's/.$/\r/' barcode_temp.txt > barcode.txt

to remove comma at the end and insert CR before the end, but still it desn't work.

Any idea?
 
Old 09-15-2004, 03:10 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
how about the so-handy-that-it-already-exists utility, unix2dos? pretty common little app, possibly already on your nix box.
 
Old 09-15-2004, 03:11 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
On slack there's todos and fromdos :)


Cheers,
Tink
 
Old 09-15-2004, 03:13 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,164

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
What exactly isn't working? I copied and pasted your text and sed script, and it seems to works fine for me (doing file on the result show it is CRLF delimited). Is it possible you don't have a newline at the end of your last line, so it's just choking on it?
 
Old 09-15-2004, 03:45 PM   #5
aurelio26
Member
 
Registered: Dec 2003
Location: CANADA
Distribution: Fedora
Posts: 40

Original Poster
Rep: Reputation: 15
When I try to load file to Palm device it stops after first line.

How should I add new line at the end? Or how should I know if its there or not?
 
Old 04-08-2008, 02:28 PM   #6
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
I don't have commas at the end of my dos/win files, I have ^M characters.
Code:
sed -e 's/^M/\^J/g'
Where the ^M is gotten by "C-v C-m" (control+v followed by control+m), and the ^J is gotten by "C-v C-j". ^J represents a linux newline, but it must be escaped with a backslash.
 
Old 04-08-2008, 02:45 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Only (almost) 4 years later .... ;D



Cheers,
Tink
 
Old 04-09-2008, 01:15 AM   #8
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
Haha, well, I had to figure it out today; thought I'd share : )
 
  


Reply

Tags
dos, newline, sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Converting numbers to currency using SED sekondborn Programming 2 10-13-2004 10:23 AM
DOS -> UNIX file conversion issue inspleak Linux - Newbie 5 07-04-2004 01:24 AM
converting text file from linux to ms dos Berhanie Linux - Newbie 4 12-24-2003 11:54 PM
Unix to DOS text Wynd Programming 5 04-18-2003 01:14 PM
converting MS-DOS files to Linux dalraidia Linux - Newbie 10 12-25-2002 08:49 PM


All times are GMT -5. The time now is 12:57 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration