help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to preserve all spacings in the file content, when parsing throu


From: alex xmb sw ratchev
Subject: Re: how to preserve all spacings in the file content, when parsing through it with while + read
Date: Fri, 7 Jun 2024 12:42:51 +0200

try IFS= read -r line

On Fri, Jun 7, 2024, 12:12 PM Ante Bilandzic <abilandzic@gmail.com> wrote:

> Hello,
>
> This is the content of example file.txt:
>
>     The shell is       both an          interactive   command language
>       and a scripting language, and is used by the operating system to
> control the execution of the system using shell scripts.
>
> I would like to parse through it using while + read, but also to preserve
> all original spacings in the file. It seems, however, that all spacings at
> the very beginning of the lines are gone, while all other spacings are
> preserved:
>
> $ while read Line; do echo "$Line"; done < file.txt
> The shell is       both an          interactive   command language
> and a scripting language, and is used by the operating system to
> control the execution of the system using shell scripts.
>
> Is there an easy way to preserve original spacings also at the beginning of
> the lines, when parsing with while + read?
>
> Thanks!
>
> Cheers,
> Ante
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]