Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"There is no distinctly American criminal class except Congress." -- Mark Twain


aus+uk / uk.comp.os.linux / while loop taking input from file via iconv

SubjectAuthor
o while loop taking input from file via iconvJava Jive

1
while loop taking input from file via iconv

<2512483888@f1.n221.z2.fidonet.fi>

  copy mid

https://www.novabbs.com/aus+uk/article-flat.php?id=360&group=uk.comp.os.linux#360

  copy link   Newsgroups: uk.comp.os.linux
Path: i2pn2.org!i2pn.org!aioe.org!jHXdSDKPKExtdJMCjskdCQ.user.46.165.242.75.POSTED!not-for-mail
From: Java.J...@f1.n221.z2.fidonet.fi (Java Jive)
Newsgroups: uk.comp.os.linux
Subject: while loop taking input from file via iconv
Date: Fri, 13 Aug 2021 20:28:07 +0200
Organization: rbb soupgate
Message-ID: <2512483888@f1.n221.z2.fidonet.fi>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="10907"; posting-host="jHXdSDKPKExtdJMCjskdCQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Comment-To: All
X-MailConverter: SoupGate-OS/2 v1.20
X-Notice: Filtered by postfilter v. 0.9.2
 by: Java Jive - Fri, 13 Aug 2021 18:28 UTC

I have the following lines in a shell script ...

while [ -n "${LINE}" ]
do
if [ -n "${LINE} ]
then
# Do processing
fi
done < "${DATA}"

..... and this works fine for all but two lines in the data file, which
contain accented characters. A file erroneously named with an e acute
needs to be renamed to have an e grave, and a filename containing an e
umlaut needs to be moved to a new location and given a new name.

I had the same problem in the Windows BATch version of the script, which
I fixed by changing the codepage to ANSI 1252 before doing the
processing in the script, and then changing it back when it was
finished. The Windows BATch program now works perfectly.

I now need something similar for the Linux shell script.

If I replace the 'done' line with ...

done < iconv -f 'CP1252' -t 'UTF-8' "${DATA}"

..... I get the following error:

<script name>: line ###: syntax error near unexpected token '-f'
<script name>: line ###: done < iconv -f 'CP1252' -t 'UTF-8' "${DATA}"

So next I tried ...

done < $(iconv -f 'CP1252' -t 'UTF-8' "${DATA}")

..... but this gives ...

<script name>: line ###: done < iconv -f 'CP1252' -t 'UTF-8'
"${DATA}": ambiguous redirect

What is is the correct incantational magic to achieve what I want?

If it's of any interest, the script renames directories and files
between versions 1 & 2 of a family archive, so that when v2 is unzipped
over v1, there won't be any old versions of files left lying around to
cause confusion.

About this, I have another question. Some of my family use Macs, not
Windows PCs. Am I right in thinking that, since recent versions of
MacOS are Linux based, they should be able to run this shell script to
achieve what those using Windows will be able to do with the BATch file?
Do I have to give them any special instructions, for example how to
get into a console?

--

Fake news kills!

I may be contacted via the contact address given on my website:
www.macfh.co.uk

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor