开发者

unix script - problem in making a text file

I am writing a s开发者_Python百科imple unix script as follows:

#!/bin/bash
mkdir tmp/temp1
cd tmp/temp1
echo "ab bc cj nn mm" > output.txt
grep 'ab' output.txt > newoutput.txt

I got following error message:

grep : No such file or directory found output.txt

but when I looked into the directory the text is created output.txt...but the type of the file was TXT....I am not sure what it is any help??


You probably have a stray '\r' (carriage return) on the line with the echo command. You're creating a file called "output.txt\r", and then trying to read a file called "output.txt" without the carriage return.

Fix the script so it uses Unix-style line endings (\n rather than \r\n). You can use the unix2dos command for this. (Note that unix2dos, unlike most filters, overwrites its input file.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜