1

Contents of the file :

PS1="$(hostname):${LOGNAME}:\${PWD} ${PROMPT} "
PS1="${FGOLD}$(hostname):${LOGNAME}:\${PWD} ${PROMPT} ${NORMAL}"
PS1=abd
PS1="$(hostname):$LOGNAME:\$PWD $PROMPT "
export PS1 LANG

Lines I want to change :

PS1="$(hostname):${LOGNAME}:\${PWD} ${PROMPT} "  

replacement line :

PS1="${FGOLD}$(hostname):${LOGNAME}:\${PWD} ${PROMPT} ${NORMAL}"
  • OK, since you have completely changed the original question, we need to know more. Are there any other lines that match PS1? If so, what should we do with them? – terdon Sep 18 '15 at 15:19
  • server is a AIX box... yes there will be other PS1 inside the file... but this above pattern alone has to be replace with below pattern... – Sivas Sep 18 '15 at 15:39
  • If there are more similar lines that need to be excluded, we need to see them to know how to identify the lines you do want changed. We can't read your mind and we don't have access to your data. You need to show us the files in question. – terdon Sep 18 '15 at 15:40
1

You could use sed:

sed 's/^PS1="\$(hostname).*\${PROMPT}.*/PS1="${FGOLD}$(hostname):${LOGNAME}:\\\${PWD} ${PROMPT} ${NORMAL}"/'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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