How to script automate unTAR of packages

Mikie kmb at
Tue Dec 29 07:38:46 PST 2009

Yes to Windows editing.
I had no idea lines were ended in LF only in Unix.

Thanks ... this is very useful and has always been a mystery to me.

-----Original Message-----
From: lfs-support-bounces at [mailto:lfs-support-bounces at] On Behalf Of Simon Geard
Sent: Monday, December 28, 2009 10:23 PM
To: lfs-support at
Subject: Re: How to script automate unTAR of packages

On Mon, 2009-12-28 at 13:49 -0500, Mikie wrote:
> Hello list,
> I have made a script file at:
> ... to unTAR my packages so I don't have to do it manually.
> When I run it I get:
> tar: /mnt/lfs/sources/zlib-1.2.3.tar.bz2\r: Cannot open: No such file or
> directory

That "\r" (carriage return) at the end of the file says your scripts is
probably saved using Windows-style end of line characters, a CR-LF pair.
Under Unix, only the LF is used for end of line, and the CR is treated
as part of the filename.

To correct it (by removing the CRs from the file), run the following

sed -i "s/^M//" LFS-6.5-untar-list

And don't use Windows to edit Unix shell scripts or config files if you
can avoid it. It just ends up causing problems like this. As a hint,
running the 'file' command on any text file will tell you if it's using
CRLF end of line characters.


More information about the lfs-support mailing list