I need to use a script (/usr/bin/ksh) to remove certain characters from a data file. The format is plain text. I want to remove the last character on a line only if it is the one specified in a parameter to the script. The specified character often needs to be the pipe character. I find I can manually write the 'sed' command line and it works (with the pipe escaped), but I can't figure out how to make it work as a parameter. The command line I am using is:
[tt]sed 's/\|$//' testin.txt > testout.txt[/tt]
and in the script I assign the first parameter to be the character to be removed and then:
[tt]sed 's/$DELIM$//' $TESTIN > $TESTOUT[/tt]
I have tried escaping the pipe on input (not ideal), quoting the pipe on input, quoting the variable, but nothing seems to work.
Any help will be much appreaciated.
-SB.
[tt]sed 's/\|$//' testin.txt > testout.txt[/tt]
and in the script I assign the first parameter to be the character to be removed and then:
[tt]sed 's/$DELIM$//' $TESTIN > $TESTOUT[/tt]
I have tried escaping the pipe on input (not ideal), quoting the pipe on input, quoting the variable, but nothing seems to work.
Any help will be much appreaciated.
-SB.