This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:scripts:basics [2014/06/11 12:39] – lunetikk | linux:scripts:basics [2021/01/07 14:55] (current) – lunetikk | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| | $VAR | inserts var whereever $VAR is placed | | $VAR | inserts var whereever $VAR is placed | ||
| | case - esac | inserts case | | | case - esac | inserts case | | ||
| - | | if - fi | inserts if | | + | | if [ " |
| + | |||
| + | ==== if conditions ==== | ||
| + | |||
| + | ^ Operator | ||
| + | | -eq | Returns true if two numbers are equivalent | ||
| + | | -lt | Returns true if a number is less than another number | ||
| + | | -gt | Returns true if a number is greater than another number | ||
| + | | == | Returns true if two strings are equivalent | ||
| + | | != | Returns true if two strings are not equivalent | ||
| + | | ! | Returns true if the expression is false | | ||
| + | | -d | Check the existence of a directory | ||
| + | | -e | Check the existence of a file | | ||
| + | | -r | Check the existence of a file and read permission | ||
| + | | -w | Check the existence of a file and write permission | ||
| + | | -x | Check the existence of a file and execute permission | ||
| + | | -z | string is null, that is, has zero length | ||
| + | | -n | string is not null. | | ||
| + | |||
| + | https:// | ||
| ===== Troubleshooting ===== | ===== Troubleshooting ===== | ||
| Line 14: | Line 33: | ||
| ==== Interpreter error ==== | ==== Interpreter error ==== | ||
| - | Problem: | + | === Problem: |
| Running your script prompts interpreter error\\ | Running your script prompts interpreter error\\ | ||
| - | Fix: \\ | + | === Fix: === |
| Open your script with vi and execute the following | Open your script with vi and execute the following | ||
| < | < | ||
| Line 23: | Line 42: | ||
| ==== Not enough rights ==== | ==== Not enough rights ==== | ||
| - | Problem: | + | === Problem: |
| Running your script requires more rights | Running your script requires more rights | ||
| - | Fix:\\ | + | === Fix: === |
| - | Make your script | + | Make your script |
| < | < | ||
| + | \\ | ||
| + | \\ | ||
| + | ~~DISCUSSION: | ||