Is there anything better (smarter) than sed?

rado84

Well-Known Member
Credits
5,074
This sed is seriously beginning to crawl on my nerves and IDK how long it will take before I kick it in its back out of my OS!
I have this universal file Saves_trick.txt which I copy inside each game's main dir which then I edit manually to create a link to the original saves dir. But I wanna save me the trouble of editing it for every game, so I thought I could make sed replace the string with brackets with the current directory name, thus making the Saves_trick file universal. For instance, the universal file contents looks like this:

Code:
ln -sTv /B/GAMES/[GAME_NAME]/MainSaves /home/rado/Документи/

So, for instance, I open terminal in NFS MW directory: [rado@arch]: /B/GAMES/NFSMW>$, then I run a script which copies the Saves_trick.txt to the same directory (cp Saves_trick.txt ./).
I tried using sed to replace the [GAME_NAME] string with the cirrent directory name:

Code:
sed -i 's/[GAME_NAME]/.//g' file.txt

but instead of replacing [GAME_NAME] with NFSMW, sed replaces everything else AROUND [GAME_NAME] with "./", leaving [GAME_NAME] untouched! :mad: So not only it doesn't use the current dir name to replace [GAME_NAME] but instead it replaces all characters of the path with "./"! MEaning that both paths become /.//.//[GAME_NAME]/./ /.//.//.//
I've never seen a dumber program than that!
 

Members online


Latest posts

Back
Top