A little help please


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting A little help please
# 15  
Old 11-14-2007
Quote:
Originally Posted by immyakram
Does my first line not have to #!/bin/bash or what u have stated.
I suggest you stick to "sh", not "bash", "zsh", "ksh", "csh" to "tcsh".

You're trying to learn the basics.
# 16  
Old 11-14-2007
Oh its just that my material is telling me to use bin/bash and all of the examples given use this too.
# 17  
Old 11-14-2007
If the documentation is telling you to use bash, then do so.

bash is a superset of sh.

sh is installed on *all* UNIX boxes, bash is only on some. So if you use sh and limit yourself to features sh supports then your script can run on more platforms.
# 18  
Old 11-14-2007
Cool. Ryte to make it easy for myself iv changed the content of my filex to just 10 line of plain and simple text. Now from what i understand the script (firstline) should take the first argument and insert it into the very top (the first line) of the file named in your second argument. The file must reatin its original name too. Any Ideas...
# 19  
Old 11-14-2007
sorry correction - I have gotta rite a script named 'firstline' that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the first line) of the file named in your second argument.
# 20  
Old 11-14-2007
Have you been introduced to "sed" ?

Code:
#!/bin/sh

echo "$1" | cat - "$2" >$$
mv $$ "$2"

# 21  
Old 11-14-2007
No not yet. I think its in the next chapter. Ill try ur syntax now.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question