Small tweek to Stackscript 1 goodstuff function

Thanks to caker for the excellent stackscripts he has written. They are a lesson and tutorial in great shell scripting techniques and automating system install and management.

Stackscript 1 has a "goodstuff" function which makes a few nice changes to the .bashrc:

    sed -i -e 's/^#PS1=/PS1=/' /root/.bashrc # enable the colorful root bash prompt
    sed -i -e "s/^#alias ll='ls -l'/alias ll='ls -al'/" /root/.bashrc # enable ll list long alias <3

I noticed the script failed on my default .bashrc cause it contained a space after the comment hash:

# PS1='\u@\h:\w\$ '
# alias ll='ls -l'

I'm not a very experienced shell scripter, but I think a simple update to the regex will ignore any spaces between the comment mark and the start of the commands which will allow the function to work on both cases:

sed -e 's/^ *#PS1=/PS1=/' bashrc
sed -e "s/^ *#alias ll='ls -l'/alias ll='ls -al'/" bashrc

Thanks,

Phil

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct