LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-21-2018, 09:21 PM   #16
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,750

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222

15 responses to this thread, and the OP still hasn't shown us what they've attempted and need help with. They're almost 4/5 of the way to being an "LQ Guru"...I don't get it.
There's a recent thread here that discussed this same issue in great depth.

Here's another idea:
Do an ASCII transfer with (S)FTP of the files from a windows box to a Linux box. That will convert the line end characters....that's pretty much the definition of an ASCII (S)FTP transfer...change nothing but the line-ends.
 
Old 09-22-2018, 04:00 AM   #17
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,765

Rep: Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764Reputation: 2764
Quote:
Originally Posted by scasey View Post
15 responses to this thread, and the OP still hasn't shown us what they've attempted and need help with. They're almost 4/5 of the way to being an "LQ Guru"...I don't get it.
There's a recent thread here that discussed this same issue in great depth.

Here's another idea:
Do an ASCII transfer with (S)FTP of the files from a windows box to a Linux box. That will convert the line end characters....that's pretty much the definition of an ASCII (S)FTP transfer...change nothing but the line-ends.
In general, SFTP does not do "edits" to the files, all transfer is binary. FTP tools do in-transfer conversions. There may be specific exceptions (I have not used EVERY tool in the world) but that is my experience. Also, I find the conversions done by dos2unix and unix2dos more accurate. Cases where the FTP tools get it wrong are rare, but not as rare as the cases where dos2unix gets it wrong.

I cannot imagine starting a thread and then not responding to suggestions, but we experience that fairly often here. I would not let it bother me much.
 
1 members found this post helpful.
Old 09-22-2018, 04:31 AM   #18
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,623
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
WHY BOTHER, when the tool has already been built, tested, optimized, and folded into the repos for distribution more than ten years ago?
A new tool could write “Don't Panic” in big friendly letters across the whole screen, when done.
 
Old 09-22-2018, 05:28 AM   #19
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by scasey View Post
15 responses to this thread, and the OP still hasn't shown us what they've attempted and need help with. They're almost 4/5 of the way to being an "LQ Guru"...I don't get it.
There's a recent thread here that discussed this same issue in great depth.

Here's another idea:
Do an ASCII transfer with (S)FTP of the files from a windows box to a Linux box. That will convert the line end characters....that's pretty much the definition of an ASCII (S)FTP transfer...change nothing but the line-ends.
I've long suspected that some membership names are actually multi-use, say at educational establishments or large companies, where the name and password are pasted up on a board and anyone who has a Linux query is encouraged to use them. In that way it would explain some of the rather "interesting" and "novice" requests from members with long posting histories. Ok, so it's a tinfoil hat theory, but I like it.

Anyway, to the OP, see https://en.wikipedia.org/wiki/Dos2unix
 
Old 09-22-2018, 09:27 AM   #20
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by stf92 View Post
Anyway, the problem as stated in post #3 can be broken into two parts. Part (a) Implement the foo command. This will be a certain sequence of linux commands, including tr.

Part (b)
Process all files in this directory ending in .unix using the foo command.
Part (a) is finished, as the following sequence of commands show.
Code:
539	 cat text01.unix 
540	 hexdump -C text01.unix 
541	 sed  's/$/\r/' text01.unix 
542	 sed  's/$/\r/' text01.unix > text01.dos
543	 hexdump -C text01.dos
Code:
bill@darkstar~/work$ cat text01.unix 
En un lugar de la mancha
de cuyo nombre no quiero acordarme,
no ha mucho que vivia un hidalgo.
bill@darkstar~/work$ hexdump -C text01.unix 
00000000  45 6e 20 75 6e 20 6c 75  67 61 72 20 64 65 20 6c  |En un lugar de l|
00000010  61 20 6d 61 6e 63 68 61  0a 64 65 20 63 75 79 6f  |a mancha.de cuyo|
00000020  20 6e 6f 6d 62 72 65 20  6e 6f 20 71 75 69 65 72  | nombre no quier|
00000030  6f 20 61 63 6f 72 64 61  72 6d 65 2c 0a 6e 6f 20  |o acordarme,.no |
00000040  68 61 20 6d 75 63 68 6f  20 71 75 65 20 76 69 76  |ha mucho que viv|
00000050  69 61 20 75 6e 20 68 69  64 61 6c 67 6f 2e 0a     |ia un hidalgo..|
0000005f
bill@darkstar~/work$ sed  's/$/\r/' text01.unix 
En un lugar de la mancha
de cuyo nombre no quiero acordarme,
no ha mucho que vivia un hidalgo.
bill@darkstar~/work$ sed  's/$/\r/' text01.unix > text01.dos
bill@darkstar~/work$ hexdump -C text01.dos
00000000  45 6e 20 75 6e 20 6c 75  67 61 72 20 64 65 20 6c  |En un lugar de l|
00000010  61 20 6d 61 6e 63 68 61  0d 0a 64 65 20 63 75 79  |a mancha..de cuy|
00000020  6f 20 6e 6f 6d 62 72 65  20 6e 6f 20 71 75 69 65  |o nombre no quie|
00000030  72 6f 20 61 63 6f 72 64  61 72 6d 65 2c 0d 0a 6e  |ro acordarme,..n|
00000040  6f 20 68 61 20 6d 75 63  68 6f 20 71 75 65 20 76  |o ha mucho que v|
00000050  69 76 69 61 20 75 6e 20  68 69 64 61 6c 67 6f 2e  |ivia un hidalgo.|
00000060  0d 0a                                             |..|
00000062
bill@darkstar~/work$ fc -l
As to part (b):
Code:
for i in *; do foo "$i"; done
That is
Code:
for i in *; do 
    sed  's/$/\r/' $i > $i.dos
done
This is not yet tested.

Last edited by stf92; 09-22-2018 at 12:55 PM.
 
Old 09-23-2018, 06:10 PM   #21
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Solution for part (b) tested. Runs OK.
 
  


Reply



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
[SOLVED] Marking a partition bootable (MS-DOS style)? stf92 Slackware 10 08-27-2017 09:06 PM
convert DOS style nardo Linux - Newbie 3 05-20-2011 01:48 PM
scripting to convert DOS '\' to UNIX style slashes poonamkhirolia Linux - Newbie 2 12-17-2010 09:35 AM
e.g., BSD style (Slackware) vs. SystemV style startup scripts haertig Slackware 5 01-03-2009 10:52 PM
Compiling kernel Debian style or Native style ? Raynus Debian 1 06-16-2008 06:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:21 AM.

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