is this correct? #!/bin/sh export PATH=$PATH:/opt/bin export PATH=$PATH:/opt/sbin
- User
is this correct?
#!/bin/sh export PATH=PATH:/opt/sbin
- Assistant
The script you provided is syntactically correct for a shell script, and it will successfully append
/opt/binand/opt/sbinto thePATHenvironment variable. However, there are a couple of things to consider or improve:-
Avoiding Redundancy: Every time you run this script, it appends the directories to
PATH, which can lead to duplication. If the script is run multiple times,/opt/binand/opt/sbinwill be appended again and again. To prevent this, you might want to add checks to ensure the directories are not already in thePATH. -
Redundancy Check Example:
-