您好,欢迎来到花图问答。
搜索
您的当前位置:首页'cat' Write Error Due to

'cat' Write Error Due to

来源:花图问答

Recently, while porting a shell script from Linux to Cygwin, I encountered an error due to Cygwin pipe problem. The error producted while executing the following commmand line:

cat a.file b.file | head -c 1M > c.file

And the error said:

cat: write error: No space left on device

According the error message, I checked the file size of a.file and b.file:

> ls -l a.file b.file
-rwx------+ 1 yestyle mkpasswd 841920 May 5 16:39 a.file
-rwx------+ 1 yestyle mkpasswd 7340032 May 4 11:16 b.file

And the disk usage information:

> df -h
Filesystem Size Used Avail Use% Mounted on
D:/cygwin/bin 60G 49G 12G 82% /usr/bin
D:/cygwin/lib 60G 49G 12G 82% /usr/lib
D:/cygwin 60G 49G 12G 82% /
C: 30G 28G 1.6G 95% /cygdrive/c
D: 60G 49G 12G 82% /cygdrive/d
E: 61G 44G 17G 74% /cygdrive/e

As you can see, the available space of disk is fairly enough for the concatenated size of a.file and b.file, which is about 7.8MB.

So the limitation of pipe buffer size became suspect, and I modified the command line as following (using a temporary file instead of pipe):

cat a.file b.file > tmp.file
head -c 1M tmp.file > c.file

And it worked! I couldn't find the accurate pipe buffer size of Cygwin (and the reference source) after Googling for a while, but it just worked.

PS: My environment information:

  • Cygwin: 1.7.18(0.263/5/3)
  • Windows: XP version 5.1 (2600.xpsp_sp3_qfe.130704-0421: Service Pack 3)

Copyright © 2019- huatuowenda.com 版权所有 湘ICP备2023022495号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务