EDIT:: be careful of the ` ' and " ! They are all different and you need to terminate each opening with a closing of the same type! ' and " can be used interchangeably, while ` is the one that really causes things to be interpreted by the shell. It (the executing `) is usually above the tab button.
Last edited by XiaoKJ; 01-07-2007 at 11:45 AM.
Come under the reign of the Idiot King...
Come to me ... I love linux!
Hey, look, another Useless Use Of Backticks! Forget the backticks (especially when all they do is call echo), just use the value directly.
In this case, the problem seems to be that when you put sed's argument in single quotes, which is the "standard" way to run sed, the shell doesn't interpret any special characters. (This is why it's the "standard" way to run sed; some of the shell special characters need to be left alone by the shell, so that sed can interpret them.) That includes the $ character, which starts a variable reference; if you use $abc inside single quotes, you'll get $abc out, not the value of the shell variable abc.
So a better fix would be to run sed like this:
i=string
sed -e "s/some string/$i/"
(I left the double quotes in so that you could use whitespace in either the match or the replacement. Either way, you'll have to replace any $ characters in both the match and the replacement if you don't want the shell to replace them with a variable's value, but without the double quotes, you'd have to escape spaces, tabs, and newlines also.)
Who can do a primitive Linux shell? This will have to get a command from the command prompt,solve it than after it finishes,comes back and waits for an other command.
hartson: I'm not sure those are exactly the kind of programming challenges that were intended. Most of them so far have been relatively small with only a few lines of code. Neither of yours are going to fall under that category.
Incidentally I've done both in my senior project from school that I'm still occasionally adding to. It's a client-server game with a console that acts like a Linux shell (albeit an extremely simple one). I would post the code, but it's neither complete nor fit for third party consumption, and it's about 4500 lines as it stands right now.
trying to learn C++ it totally sucks...... i need to write a blackjack program and well im having to many problems with stupid syntax ........ I like web programming (php , )
"Software is like sex: it's better when its free."
-LINUS TORVALDS
What happens when you need to make something that is impossible with php?
If C++ isn't for you, then try python, java etc etc... there are just too many languages to swear off programming without trying them.
right now im *attempting* to create some sort of mud client in python, what i have is a main function that gives a desciption and asks for an input, and in it there's an if/elif/else statement that calls other functions based on the input.
At the end of each function, the main descript one will be called.
C++ is not easy, but it gives you a lot of power once you get to know it (sometimes too much).
boxxertrumps: Are you saying that the main function is going to call individual functions that will then call the main function again? If so, eventually you're going to exhaust your stack space and your app will crash. Just let the functions return normally and add a loop to the main function. Of course if that's not what you're planning to do then never mind.