How to Use the Linux set command – Guide

The Linux set command is an implicit shell command that allows you to show or set shell and weather factors. In this guide, we cover the set command and show you the different ways the command line utility can be used.

Syntax

Shell Korn (ksh):

Options: Bourne Shell (sh)

-a, –archive Create an archive of the current directory. -c, –compress Compress the archive. -d, –delete Delete the archive after it is created. -f, –force Overwrite any existing files in the archive with the contents of the current directory. “The set built-in command has three options: –archive, –compress, and–delete.” ..

define var [n] = “word”

The -f flag causes the flags for the file name to be turned off. The -g flag causes the flags for the directory name to be turned off. The -v flag causes the flags for the verbose mode to be turned off.

For each name, the unset command removes the corresponding variable or function value. Special variables PATH, PS1, PS2, MAILCHECK and IF cannot be deselected.

If you want to export a list of variables or functions, use the export command. If no arguments are given, the names of variables marked for export during current shell execution are listed. ..

Options: C Shell (csh)

The empty string (null) is not assigned to a variable.

“Word A” (word list)

  1. “Apple”
  2. “Banana”
  3. “Orange”
  4. “Pear”
  5. “Pineapple” ..

Values are the command and filename expanded before being assigned. The var formset[n]= word replaces the nth word in a value of several words per word. ..

Unsetting variables removes all variables whose names match the pattern. All variables are removed by “unset *”; however, it’s a bad idea if you don’t know what you’re doing. ..

-h, –help show this help message and exit -v, –version show the version number and exit The set command can be used to set the shell’s environment variables.

-An array assignment. Remove the variable name and assign values ​​sequentially from the arg list. If + A is used, the variable name is not unconfigured first.-a All subsequent ​​variables that are set are automatically exported.-e If a command has a non-zero exit status, run the ERR trap (if configured) and exit . This mode is disabled when reading profiles.-f Disable filename generation (globbing) .-h Each command becomes a traced alias when first encountered.-k All variable assignment arguments are placed in environment for a command, not just those preceding the command name. -m Background jobs run in a separate process group and a line is printed upon completion. The exit status of background jobs is reported in a completion message. On systems with task control, this flag is automatically enabled for interactive shells.-n Read the commands and check for syntax errors, but do not execute them. Ignored for interactive shells. ..

The -A flag causes the flags to be turned off for all variables.

The namelist provides a list of variables that are not automatically assigned values. If the -f flag is set, names refer to function names. If disabling ERRNO, LINENO, MAILCHECK, OPTARG, OPTIND, RANDOM, SECONDS, TMOUT, and _ removes their special meaning; even if they are assigned later.

When unsetting variables, the values and attributes of the provided variables are cleared. Read-only variables cannot be unset. If the -f flag is set, the names refer to the function names. Disabling ERRNO, LINENO, MAILCHECK, OPTARG, OPTIND, RANDOM, SECONDS, TMOUT, and _ removes their special meaning even if they are assigned later. ..

  • ksh -c ’export PWD=/tmp/foo'
  • ksh -c ’export PWD=/tmp/bar'

When the command completes, the variable assignment lists that preceded it remain in effect. ..

After variable assignments, I/O redirects are processed.

Scripts containing errors are aborted when they are encountered. This can cause problems for the writer, as well as the audience, since it can prevent the story from continuing.

The following is a list of commands that can be used to change the value of a variable: ** tilde replacement is performed after the = sign, and word splitting and filename generation are not performed.

Final note

The Linux set command is a powerful tool that can be used to manage your system’s settings. This guide will teach you how to use set to customize your system’s settings. If you have any questions about this article, feel free to ask us in the comments section below. Finally, if you’d like to share this article with your friends, please do so by clicking the share button below. ..