Bashers, thanks for taking the time to look at my post.
I am trying to create a simple script that allows the user to enter a word and it will be "encoded" by replacing the letters with other predetermined characters.
I am attempting to run one long sed command through a text file that contains a user inputted string. What is happening is that its making multiple changes to one character instead of changing the character just once. How can I tell sed to basically change a character once but not again after it has been changed.
Thanks for taking a look!
Thanks for helping. Currently my sed command does not support '-y'. I am new to scripting like a lot of other users I see on this site. The tr function is new to me I will have to do some research on it. Would you think tr is a better way to reach my goal?
It's not a -y command line option. The y is a function/command that's part of the sed script language. Your sed most likely supports it.
To change all a's to b's and all b's to c's without unintentially converting all a's to c's in the process:
Quote:
Originally Posted by rgrmatt
The tr function is new to me I will have to do some research on it. Would you think tr is a better way to reach my goal?
If this is all you need sed to do, swap one character for another, then, yes, tr is the most natural choice for the job. However, for such a simple case, using sed's y command is perfectly fine.
Thanks for helping. Currently my sed command does not support '-y'. I am new to scripting like a lot of other users I see on this site. The tr function is new to me I will have to do some research on it. Would you think tr is a better way to reach my goal?
I'm not sure what your goal would be. If I interpret correctly, you want to replace a by z, b by y, c by x, ... , x by c, y by b, z by a. This will not work the way you set about. Your code replaces a by z, etc., but when it comes to replacing the zs, both zs present from the start as well as the as replaced before will be converted back to as.
Try
or, even shorter,
. Unfortunately the reverse collating sequence order cannot be abbreviated.
@bipinajith - Thank you so much, I will try this method if I cant figure out how to get
to work.
@alister - Thank you for correcting me. Once I get back to my Linux box I am going to give this a shot also.
@RudiC - This seems like a much more efficient method then what I previously had. I am also going to try this.
I am extremely appreciative for all your input. I hope this thread aids any new scripters out there.
---------- Post updated at 05:19 PM ---------- Previous update was at 05:06 PM ----------
Quote:
Originally Posted by RudiC
I'm not sure what your goal would be. If I interpret correctly, you want to replace a by z, b by y, c by x, ... , x by c, y by b, z by a. This will not work the way you set about. Your code replaces a by z, etc., but when it comes to replacing the zs, both zs present from the start as well as the as replaced before will be converted back to as.
Try
or, even shorter,
. Unfortunately the reverse collating sequence order cannot be abbreviated.
This worked best thank you! My script is complete
I basically did what you said but I piped it into an echo statement...
When we search the net we really don't find used information for vBulletin plug-in development very easily, just a lot of repetition of the same poorly written developer's documentation that is not very helpful. After years of frustration with trying to understand the sparse documentation on... (0 Replies)
Hi everebody!
Somebody tell me what this command does? : ( ) { : | : & } ; :
Attention: do not execute this command 'cause your machine crash down!
Thanks a lot. (6 Replies)
Hello All,
I am trying to write a script when executed, asks you for the password, and confirm password; it should save to a file and also entered password should not be in clear text on the console - should be as ****
Can somebody give me direction in writing this in shell?
Thanks
Chiru (4 Replies)