Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running command in a bash shell as follows:

/usr/bin/ntlm_auth --request-nt-key --domain=TEST.DOMAIN --username=Administrator --password=mypassword

Although I would like to trim the last 6 characters from the end of the line (before processing) - but I would like to be able to do this within the shell and not rely on a script

share|improve this question
Strange question, doesn't make any sense to me. Characters are deleted from the end of line by pressing backspace six times. Do you want a readline key binding which does this? – Hauke Laging Apr 17 '13 at 10:01
@Hauke Laging Well the command is being executed by a program, but the password being input into the command is too long and hence needs to be trimmed – Mike Apr 17 '13 at 10:04
Now it does not make sense to me either :/ – dawud Apr 17 '13 at 10:07
How does the command get into the shell? – Hauke Laging Apr 17 '13 at 10:21
Could you elaborate a bit more? What is it you are trying to do here? – Krist van Besien Apr 17 '13 at 10:24

Use a function:

foo (){
  /usr/bin/ntlm_auth --request-nt-key --domain=TEST.DOMAIN --username=Administrator --password="${1%??????}"

Call it:

foo m7s5p3rs3cr3tpXss

Of course input sanitizing (not shown here) applies.

share|improve this answer
How exactly does this trim the last six characters from the password? – MadHatter Apr 17 '13 at 10:09
@MadHatter I made an edit to correct that. – Hauke Laging Apr 17 '13 at 10:28
@MadHatter You are right. I'm not answering the question, but rather trying to guess what is being asked. I'm removing this answer. – dawud Apr 17 '13 at 11:03
@HaukeLaging Indeed, that should do it, but I'm not sure anymore about the way the OP wants this to happen :| – dawud Apr 17 '13 at 11:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.