Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

When the going gets tough, the tough go grab a beer.


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

SubjectAuthor
o Re: while loop taking input from file via iconvSpiros Bousbouras

1
Re: while loop taking input from file via iconv

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

  copy mid

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

  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: Spiros.B...@f1.n221.z2.fidonet.fi (Spiros Bousbouras)
Newsgroups: uk.comp.os.linux
Subject: Re: while loop taking input from file via iconv
Date: Sat, 14 Aug 2021 00:30:33 +0200
Organization: rbb soupgate
Message-ID: <3829437239@f1.n221.z2.fidonet.fi>
References: <2512483888@f0.n0.z0.fidonet.org>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="56952"; posting-host="jHXdSDKPKExtdJMCjskdCQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Comment-To: All
X-Notice: Filtered by postfilter v. 0.9.2
X-MailConverter: SoupGate-OS/2 v1.20
 by: Spiros Bousbouras - Fri, 13 Aug 2021 22:30 UTC

On Fri, 13 Aug 2021 20:28:07 +0100
Java Jive <java@evij.com.invalid> wrote:
> I have the following lines in a shell script ...
>
> while [ -n "${LINE}" ]
> do
> if [ -n "${LINE} ]

There is a double quote missing in the previous 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.

Just to be clear , the above loop will exit at the first empty line read
from $DATA even though the file may have more (possibly non empty) lines
after that. Is this what you want ? It seems doubtful because you also have
the test if [ -n "${LINE} ] .

> 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?

Assuming that the example code above is really what you want then

iconv -f 'CP1252' -t 'UTF-8' "${DATA}" | while read LINE ; do
if [ -z "${LINE}" ] ; then break ; fi
# Do processing
done

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor