哇,这不可能是错的。错在哪里?

哇,这不可能是错的。错在哪里?

我先把这个放出来,这是我的 shell 脚本作业。但是,我的工作已经完成了。只是由于某种原因,它无法正常运行。我已经问过 2 名游戏开发人员毕业生和一些同行,但没有人能弄清楚为什么它不起作用!出了什么问题?

多行不带分号

-bash-3.2$ chmod u+x names
-bash-3.2$ cat names
grep 94112 famous.dat | cut -c6-19 > famous.last3
grep 94112 famous.dat | cut -c21-35 > famous.first3
paste famous.first3 famous.last3
rm famous.first3
rm famous.last3
-bash-3.2$ names
paste: famous.first3 : Cannot open the file.
-bash-3.2$

分号,所有内容在一行中

-bash-3.2$ cat names 
grep 94112 famous.dat | cut -c6-19 > famous.last3; grep 94112 famous.dat | cut -c21-35 > famous.first3; paste famous.first3 famous.last3; rm famous.first3; rm famous.last3;
-bash-3.2$ names
nina            simone        
bob             marley        
michael         franti        
keith           richards      
: command not found
-bash-3.2$

半彩色多线条

-bash-3.2$ cat names
grep 94112 famous.dat | cut -c6-19 > famous.last3; 
grep 94112 famous.dat | cut -c21-35 > famous.first3; 
paste famous.first3 famous.last3; 
rm famous.first3; 
rm famous.last3;
-bash-3.2$ names
: command not found
: command not found
nina            simone        
bob             marley        
michael         franti        
keith           richards      
: command not found
: command not found
: command not found
-bash-3.2$

尝试使用 dos2unix:

-bash-3.2$ dos2unix names namesunix
-bash: dos2unix: command not found

答案1

行尾。尝试dos2unix

相关内容