-1

I am going to put this out there first, this is my shell script homework. However, I am finished with my work. It is just not running properly for some reason. I already asked 2 game developer graduates and a few peers and no one could figure out why is this not working! What is wrong?

Multiple lines without semi-colon

-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$

Semi-colon with everything in one line

-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$

Semi-color with multiple lines

-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$

Attempt to use dos2unix:

-bash-3.2$ dos2unix names namesunix
-bash: dos2unix: command not found
  • what operating system? – JT.WK Oct 6 '10 at 3:28
  • No idea, how can I check? – Doug Oct 6 '10 at 3:32
  • obvious finger pointing at "." in PATH, poke poke – Hubert Kario Oct 6 '10 at 3:39
  • You haven't told us what you think it's supposed to do, so how can anyone be expected to tell you where you've gone wrong? If you don't even know which OS you're running this on you really need to go back to basics, because that's the very first thing you should have found out. You also get a -1 for the arrogant title. – John Gardeniers Oct 6 '10 at 4:18
1

Line endings. Try dos2unix.

| improve this answer | |
  • -bash-3.2$ dos2unix names namesunix -bash: dos2unix: command not found – Doug Oct 6 '10 at 3:20
  • pico or nano will re-save with proper linebreaks as well. – Warner Oct 6 '10 at 4:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.