> On 8 fev, 11:04, pk<p...@pk.invalid> wrote:
>> On Wed, 8 Feb 2012 04:54:29 -0800 (PST), contracer<contrace...@gmail.com>
>> wrote:
>>> Hi,
>>> How could I replace all spaces in a file with % character, usind "for"
>>> loop ?
>> Obviously not, the for loop itself isn't used to replace characters. Why do
>> you need to use a for loop?
> Which Unix command could I use to verify character by character in a
> file ?
It's not clear if you're talking about replacing spaces in a file name or in a files contents, if you're issue is how to do the replacement in 1 file or if you know how to do it for 1 file but can't figure out how to do it for many files.
You could really stand to post some sample input and expected output so we're not all guessing.
> On 2/8/2012 7:45 AM, contracer wrote:
>> [...]
> [...]>
> You could really stand to post some sample input and expected output so
> we're not all guessing.
As long as we're able to post just 5 or 6 character as response the
wasted time is not that that significant. ;-)
On Feb 8, 4:54 am, contracer <contrace...@gmail.com> wrote:
> How could I replace all spaces in a file with % character, usind "for" loop ?
Why does it necessarily have to use the "for" loop; isn't the looping
flow-of-control code up to you and your particular implementation?
(Actually, the "while" or "until" loop should be more pertainent....)
Are you talking about percent encoding? (Probably not). This
code fragment should show more light on the technique:
Q25. How can I convert %XX values to ascii?
A25. You can convert this to a sequence of ANSI C strings and
then eval that string, for example suppose the variable 'foo' contains
%XX strings, then:
The above uses ksh version 1993 or newer features. If you want
a CGI / URL encoding/unencoding function in shell, there are many
to be found, including one from the author of kornshell: