unix

How to choose which version of python runs from terminal?

依然范特西╮ 提交于 2020-11-30 04:40:39
问题 I have a few different versions of python on my computer. How do I choose which one is run from my terminal when I type "python" into the prompt? 回答1: Use which to see where your python command resides. Then use ls -l to find out where it really is. Then link the one you want instead. Note that the other installed versions are usually all available by their respective names. $ which python /usr/bin/python $ ls -l /usr/bin/python lrwxrwxrwx 1 root root 9 Jun 18 2013 /usr/bin/python -> python2

Use sed to edit crontab

匆匆过客 提交于 2020-11-29 08:31:36
问题 I am writing a sed command that should uncomment an entry in crontab. Is there a better way to do this? The first option that comes to mind is sed. Example: crontab -l # 5 * * * 3 bash test.sh The sed command should uncomment this entry. This is what I have now. sed "s#\# 5 * * * 3 bash test.sh#5 * * * 3 bash test.sh#" Obviously this sed command doesn't do the task. ps:the sed command will eventually make its way into a script. 回答1: Sed is great for matching specific regular expressions and

Use sed to edit crontab

♀尐吖头ヾ 提交于 2020-11-29 08:31:08
问题 I am writing a sed command that should uncomment an entry in crontab. Is there a better way to do this? The first option that comes to mind is sed. Example: crontab -l # 5 * * * 3 bash test.sh The sed command should uncomment this entry. This is what I have now. sed "s#\# 5 * * * 3 bash test.sh#5 * * * 3 bash test.sh#" Obviously this sed command doesn't do the task. ps:the sed command will eventually make its way into a script. 回答1: Sed is great for matching specific regular expressions and

sed - Commenting a line matching a specific string AND that is not already commented out

*爱你&永不变心* 提交于 2020-11-25 06:19:30
问题 I have the following test file AAA BBB CCC Using the following sed I can comment out the BBB line. # sed -e '/BBB/s/^/#/g' -i file I'd like to only comment out the line if it does not already has a # at the begining. # sed -e '/^#/! /BBB/s/^/#/g' file sed: -e expression #1, char 7: unknown command: `/' Any ideas how I can achieve this? 回答1: Assuming you don't have any lines with multiple # s this would work: sed -e '/BBB/ s/^#*/#/' -i file Note: you don't need /g since you are doing at most

sed - Commenting a line matching a specific string AND that is not already commented out

我与影子孤独终老i 提交于 2020-11-25 06:14:19
问题 I have the following test file AAA BBB CCC Using the following sed I can comment out the BBB line. # sed -e '/BBB/s/^/#/g' -i file I'd like to only comment out the line if it does not already has a # at the begining. # sed -e '/^#/! /BBB/s/^/#/g' file sed: -e expression #1, char 7: unknown command: `/' Any ideas how I can achieve this? 回答1: Assuming you don't have any lines with multiple # s this would work: sed -e '/BBB/ s/^#*/#/' -i file Note: you don't need /g since you are doing at most