1 .\"
   2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
   3 .\" permission to reproduce portions of its copyrighted documentation.
   4 .\" Original documentation from The Open Group can be obtained online at
   5 .\" http://www.opengroup.org/bookstore/.
   6 .\"
   7 .\" The Institute of Electrical and Electronics Engineers and The Open
   8 .\" Group, have given us permission to reprint portions of their
   9 .\" documentation.
  10 .\"
  11 .\" In the following statement, the phrase ``this text'' refers to portions
  12 .\" of the system documentation.
  13 .\"
  14 .\" Portions of this text are reprinted and reproduced in electronic form
  15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
  16 .\" Standard for Information Technology -- Portable Operating System
  17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
  18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
  19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
  20 .\" between these versions and the original IEEE and The Open Group
  21 .\" Standard, the original IEEE and The Open Group Standard is the referee
  22 .\" document.  The original Standard can be obtained online at
  23 .\" http://www.opengroup.org/unix/online.html.
  24 .\"
  25 .\" This notice shall appear on any product containing this material.
  26 .\"
  27 .\" The contents of this file are subject to the terms of the
  28 .\" Common Development and Distribution License (the "License").
  29 .\" You may not use this file except in compliance with the License.
  30 .\"
  31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  32 .\" or http://www.opensolaris.org/os/licensing.
  33 .\" See the License for the specific language governing permissions
  34 .\" and limitations under the License.
  35 .\"
  36 .\" When distributing Covered Code, include this CDDL HEADER in each
  37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  38 .\" If applicable, add the following below this CDDL HEADER, with the
  39 .\" fields enclosed by brackets "[]" replaced with your own identifying
  40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  41 .\"
  42 .\"
  43 .\" Copyright 1989 AT&T
  44 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
  45 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
  46 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
  47 .\" Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
  48 .\"
  49 .TH ALIAS 1 "Feb 9, 2021"
  50 .SH NAME
  51 alias, unalias \- create or remove a pseudonym or shorthand for a command or
  52 series of commands
  53 .SH SYNOPSIS
  54 .nf
  55 \fB/usr/bin/alias\fR [\fIalias-name\fR[= \fIstring\fR...]]
  56 .fi
  57 
  58 .LP
  59 .nf
  60 \fB/usr/bin/unalias\fR \fIalias-name\fR...
  61 .fi
  62 
  63 .LP
  64 .nf
  65 \fB/usr/bin/unalias\fR \fB-a\fR
  66 .fi
  67 
  68 .SS "\fBcsh\fR"
  69 .nf
  70 \fBalias\fR [\fIname\fR [\fIdef\fR]]
  71 .fi
  72 
  73 .LP
  74 .nf
  75 \fBunalias\fR \fIpattern\fR
  76 .fi
  77 
  78 .SS "\fBksh93\fR"
  79 .nf
  80 \fBalias\fR [\fB-ptx\fR] [\fIname\fR[= \fIvalue\fR]...]
  81 .fi
  82 
  83 .LP
  84 .nf
  85 \fBunalias\fR [\fB-a\fR] [\fIname\fR...]
  86 .fi
  87 
  88 .SH DESCRIPTION
  89 The \fBalias\fR and \fBunalias\fR utilities create or remove a pseudonym or
  90 shorthand term for a command or series of commands, with different
  91 functionality in the C-shell and Korn shell environments.
  92 .SS "\fB/usr/bin/alias\fR"
  93 The \fBalias\fR utility creates or redefines alias definitions or writes the
  94 values of existing alias definitions to standard output. An alias definition
  95 provides a string value that replaces a command name when it is encountered.
  96 .sp
  97 .LP
  98 An alias definition affects the current shell execution environment and the
  99 execution environments of the subshells of the current shell. When used as
 100 specified by this document, the alias definition does not affect the parent
 101 process of the current shell nor any utility environment invoked by the shell.
 102 .SS "\fB/usr/bin/unalias\fR"
 103 The \fBunalias\fR utility removes the definition for each alias name specified.
 104 The aliases are removed from the current shell execution environment. The
 105 \fB-a\fR option removes all alias definitions from the current execution
 106 environment.
 107 .SS "\fBcsh\fR"
 108 \fBalias\fR assigns \fIdef\fR to the alias \fIname\fR. The assigned \fIdef\fR
 109 is a list of words that can contain escaped history-substitution metasyntax.
 110 \fIname\fR is not allowed to be \fBalias\fR or \fBunalias\fR. If \fIdef\fR is
 111 omitted, the alias \fIname\fR is displayed along with its current definition.
 112 If both \fIname\fR and \fIdef\fR are omitted, all aliases are displayed.
 113 .sp
 114 .LP
 115 Because of implementation restrictions, an alias definition must have been
 116 entered on a previous command line before it can be used.
 117 .sp
 118 .LP
 119 \fBunalias\fR discards aliases that match (filename substitution)
 120 \fIpattern\fR. All aliases can be removed by `\fBunalias *\fR'.
 121 .SS "\fBksh93\fR"
 122 \fBalias\fR creates or redefines alias definitions or writes the existing alias
 123 definitions to standard output.
 124 .sp
 125 .LP
 126 An alias definition provides a string value that replaces a command name when
 127 the command is read. Alias names can contain any printable character that is
 128 not special to the shell. If an alias value ends in a SPACE or TAB, the word
 129 following the command name the alias replaces is also checked to see whether it
 130 is an alias.
 131 .sp
 132 .LP
 133 If no names are specified, the names and values of all aliases are written to
 134 standard output. Otherwise, for each name that is specified, and
 135 \fB=\fR\fIvalue\fR is not specified, the current value of the alias
 136 corresponding to name is written to standard output. If \fB=\fR\fIvalue\fR is
 137 specified, the alias name is created or redefined.
 138 .sp
 139 .LP
 140 \fBalias\fR is built-in to the shell as a declaration command so that field
 141 splitting and pathname expansion are not performed on the arguments. Tilde
 142 expansion occurs on \fIvalue\fR. An alias definition only affects scripts read
 143 by the current shell environment. It does not affect scripts run by this shell.
 144 .sp
 145 .LP
 146 \fBunalias\fR removes the definition of each named alias from the current shell
 147 execution environment, or all aliases if \fB-a\fR is specified. It does not
 148 affect any commands that have already been read and subsequently executed.
 149 .SH OPTIONS
 150 The following option is supported by \fBunalias\fR:
 151 .sp
 152 .ne 2
 153 .na
 154 \fB\fB-a\fR\fR
 155 .ad
 156 .RS 6n
 157 Removes all alias definitions from the current shell execution environment.
 158 .RE
 159 
 160 .SS "\fBksh93\fR"
 161 The following options are supported by \fBalias\fR:
 162 .sp
 163 .ne 2
 164 .na
 165 \fB\fB-p\fR\fR
 166 .ad
 167 .RS 6n
 168 Causes the output to be in the form of \fBalias\fR commands that can be used as
 169 input to the shell to recreate the current aliases.
 170 .RE
 171 
 172 .sp
 173 .ne 2
 174 .na
 175 \fB\fB-t\fR\fR
 176 .ad
 177 .RS 6n
 178 Specifies tracked aliases.
 179 .sp
 180 Tracked aliases connect a command name to the command's pathname, and are reset
 181 when the \fBPATH\fR variable is unset. The tracked aliases feature is now
 182 obsolete.
 183 .RE
 184 
 185 .sp
 186 .ne 2
 187 .na
 188 \fB\fB-x\fR\fR
 189 .ad
 190 .RS 6n
 191 Ignored, this option is obsolete.
 192 .RE
 193 
 194 .sp
 195 .LP
 196 The following option is supported by \fBunalias\fR:
 197 .sp
 198 .ne 2
 199 .na
 200 \fB\fB-a\fR\fR
 201 .ad
 202 .RS 6n
 203 Causes all alias definitions to be removed. \fIname\fR operands are optional
 204 and ignored if specified.
 205 .RE
 206 
 207 .SH OPERANDS
 208 The following operands are supported:
 209 .SS "\fBalias\fR"
 210 .ne 2
 211 .na
 212 \fB\fIalias-name\fR\fR
 213 .ad
 214 .RS 14n
 215 Write the alias definition to standard output.
 216 .RE
 217 
 218 .SS "\fBunalias\fR"
 219 .ne 2
 220 .na
 221 \fB\fIalias-name\fR\fR
 222 .ad
 223 .RS 21n
 224 The name of an alias to be removed.
 225 .RE
 226 
 227 .sp
 228 .ne 2
 229 .na
 230 \fB\fIalias-name\fR\fB=\fR\fIstring\fR\fR
 231 .ad
 232 .RS 21n
 233 Assign the value of \fIstring\fR to the alias \fIalias-name\fR.
 234 .RE
 235 
 236 .sp
 237 .LP
 238 If no operands are specified, all alias definitions are written to standard
 239 output.
 240 .SH OUTPUT
 241 The format for displaying aliases (when no operands or only \fIname\fR operands
 242 are specified) is:
 243 .sp
 244 .in +2
 245 .nf
 246 "%s=%s\en" \fIname\fR, \fIvalue\fR
 247 .fi
 248 .in -2
 249 .sp
 250 
 251 .sp
 252 .LP
 253 The \fIvalue\fR string is written with appropriate quoting so that it is
 254 suitable for reinput to the shell.
 255 .SH EXAMPLES
 256 \fBExample 1 \fRModifying a Command's Output
 257 .sp
 258 .LP
 259 This example specifies that the output of the \fBls\fR utility is columnated
 260 and more annotated:
 261 
 262 .sp
 263 .in +2
 264 .nf
 265 example% \fBalias ls="ls \(miCF"\fR
 266 .fi
 267 .in -2
 268 .sp
 269 
 270 .LP
 271 \fBExample 2 \fRRepeating Previous Entries in the Command History File
 272 .sp
 273 .LP
 274 This example creates a simple "redo" command to repeat previous entries in the
 275 command history file:
 276 
 277 .sp
 278 .in +2
 279 .nf
 280 example% \fBalias r='fc \(mis'\fR
 281 .fi
 282 .in -2
 283 .sp
 284 
 285 .LP
 286 \fBExample 3 \fRSpecifying a Command's Output Options
 287 .sp
 288 .LP
 289 This example provides that the \fBdu\fR utility summarize disk output in units
 290 of 1024 bytes:
 291 
 292 .sp
 293 .in +2
 294 .nf
 295 example% \fBalias du=du \(mik\fR
 296 .fi
 297 .in -2
 298 .sp
 299 
 300 .LP
 301 \fBExample 4 \fRDealing with an Argument That is an Alias Name
 302 .sp
 303 .LP
 304 This example sets up the \fBnohup\fR utility so that it can deal with an
 305 argument that is an alias name:
 306 
 307 .sp
 308 .in +2
 309 .nf
 310 example% \fBalias nohup="nohup "\fR
 311 .fi
 312 .in -2
 313 .sp
 314 
 315 .SH ENVIRONMENT VARIABLES
 316 See \fBenviron\fR(5) for descriptions of the following environment variables
 317 that affect the execution of \fBalias\fR and \fBunalias\fR: \fBLANG\fR,
 318 \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 319 .SH EXIT STATUS
 320 The following exit values are returned:
 321 .sp
 322 .ne 2
 323 .na
 324 \fB\fB0\fR\fR
 325 .ad
 326 .RS 5n
 327 Successful completion.
 328 .RE
 329 
 330 .SS "\fBalias\fR"
 331 .ne 2
 332 .na
 333 \fB\fB>0\fR\fR
 334 .ad
 335 .RS 6n
 336 One of the \fIalias-name\fR operands specified did not have an alias
 337 definition, or an error occurred.
 338 .RE
 339 
 340 .SS "\fBunalias\fR"
 341 .ne 2
 342 .na
 343 \fB\fB>0\fR\fR
 344 .ad
 345 .RS 6n
 346 One of the \fIalias-name\fR operands specified did not represent a valid alias
 347 definition, or an error occurred.
 348 .RE
 349 
 350 .SH ATTRIBUTES
 351 See \fBattributes\fR(5) for descriptions of the following attributes:
 352 .SS "\fBcsh, ksh\fR"
 353 .TS
 354 box;
 355 c | c
 356 l | l .
 357 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 358 _
 359 Interface Stability     Committed
 360 _
 361 Standard        See \fBstandards\fR(5).
 362 .TE
 363 
 364 .SS "\fBksh93\fR"
 365 .TS
 366 box;
 367 c | c
 368 l | l .
 369 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 370 _
 371 Interface Stability     Uncommitted
 372 .TE
 373 
 374 .SH SEE ALSO
 375 \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBshell_builtins\fR(1),
 376 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)