A little help please


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting A little help please
# 22  
Old 11-14-2007
Now you tell me

how and why it works and
what each part is actually doing, and
any problems with it.
# 23  
Old 11-14-2007
Hmmmmmmmm.... files called filex and the script that im creating now and where syntax is called firstline. But still dont knw what to reference after $'s
# 24  
Old 11-14-2007
so you should have put my code in a file called "firstline"

Then run it as follows...

Code:
chmod +x firstline
echo "original line" >testfile
cat testfile
./firstline "another line" testfile
cat testfile

# 25  
Old 11-14-2007
Not working Smilie get a error after ./
# 26  
Old 11-14-2007
Post the contents of your file and the results from your screen.

Eg,

Code:
bash-2.05$ cat firstline
#!/bin/sh

echo "$1" | cat - "$2" >$$
mv $$ "$2"
bash-2.05$ chmod +x firstline
bash-2.05$ echo "original line" >testfile
bash-2.05$ cat testfile
original line
bash-2.05$ ./firstline "another line" testfile
bash-2.05$ cat testfile
another line
original line
bash-2.05$


Last edited by porter; 11-14-2007 at 09:16 PM..
# 27  
Old 11-14-2007
#!/bin/bash

file=$HOME/file1

{read $1

} < $2

echo "this first line in $2 is "$1".

then running it - sh script_name $1 $2

Iv been tryna play around with this...
# 28  
Old 11-14-2007
So where in your program do you write out the new file with the new first line inserted?
Login or Register to Ask a Question

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