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 .\"
  48 .TH ALIAS 1 "Apr 8, 2008"
  49 .SH NAME
  50 alias, unalias \- create or remove a pseudonym or shorthand for a command or
  51 series of commands
  52 .SH SYNOPSIS
  53 .LP
  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 .LP
  70 .nf
  71 \fBalias\fR [\fIname\fR [\fIdef\fR]]
  72 .fi
  73 
  74 .LP
  75 .nf
  76 \fBunalias\fR \fIpattern\fR
  77 .fi
  78 
  79 .SS "\fBksh\fR"
  80 .LP
  81 .nf
  82 \fBalias\fR [\fB-tx\fR] [\fIname\fR[= \fIvalue\fR]...]
  83 .fi
  84 
  85 .LP
  86 .nf
  87 \fBunalias\fR \fIname\fR...
  88 .fi
  89 
  90 .LP
  91 .nf
  92 \fBunalias\fR [\fB-a\fR]
  93 .fi
  94 
  95 .SS "\fBksh93\fR"
  96 .LP
  97 .nf
  98 \fBalias\fR [\fB-ptx\fR] [\fIname\fR[= \fIvalue\fR]...]
  99 .fi
 100 
 101 .LP
 102 .nf
 103 \fBunalias\fR [\fB-a\fR] [\fIname\fR...]
 104 .fi
 105 
 106 .SH DESCRIPTION
 107 .sp
 108 .LP
 109 The \fBalias\fR and \fBunalias\fR utilities create or remove a pseudonym or
 110 shorthand term for a command or series of commands, with different
 111 functionality in the C-shell and Korn shell environments.
 112 .SS "\fB/usr/bin/alias\fR"
 113 .sp
 114 .LP
 115 The \fBalias\fR utility creates or redefines alias definitions or writes the
 116 values of existing alias definitions to standard output. An alias definition
 117 provides a string value that replaces a command name when it is encountered.
 118 .sp
 119 .LP
 120 An alias definition affects the current shell execution environment and the
 121 execution environments of the subshells of the current shell. When used as
 122 specified by this document, the alias definition does not affect the parent
 123 process of the current shell nor any utility environment invoked by the shell.
 124 .SS "\fB/usr/bin/unalias\fR"
 125 .sp
 126 .LP
 127 The \fBunalias\fR utility removes the definition for each alias name specified.
 128 The aliases are removed from the current shell execution environment. The
 129 \fB-a\fR option removes all alias definitions from the current execution
 130 environment.
 131 .SS "\fBcsh\fR"
 132 .sp
 133 .LP
 134 \fBalias\fR assigns \fIdef\fR to the alias \fIname\fR. The assigned \fIdef\fR
 135 is a list of words that can contain escaped history-substitution metasyntax.
 136 \fIname\fR is not allowed to be \fBalias\fR or \fBunalias\fR. If \fIdef\fR is
 137 omitted, the alias \fIname\fR is displayed along with its current definition.
 138 If both \fIname\fR and \fIdef\fR are omitted, all aliases are displayed.
 139 .sp
 140 .LP
 141 Because of implementation restrictions, an alias definition must have been
 142 entered on a previous command line before it can be used.
 143 .sp
 144 .LP
 145 \fBunalias\fR discards aliases that match (filename substitution)
 146 \fIpattern\fR. All aliases can be removed by `\fBunalias *\fR'.
 147 .SS "\fBksh\fR"
 148 .sp
 149 .LP
 150 \fBalias\fR with no arguments prints the list of aliases in the form
 151 \fIname=value\fR on standard output. An \fBalias\fR is defined for each name
 152 whose \fIvalue\fR is specified. A trailing space in \fIvalue\fR causes the next
 153 word to be checked for alias substitution. The \fB-t\fR flag is used to set and
 154 list tracked aliases. The value of a tracked alias is the full pathname
 155 corresponding to the specified \fIname\fR. The value becomes undefined when the
 156 value of \fBPATH\fR is reset but the aliases remained tracked. Without the
 157 \fB-t\fR flag, for each \fIname\fR in the argument list for which no
 158 \fIvalue\fR is specified, the name and value of the alias is printed. The
 159 \fB-x\fR flag is used to set or print \fIexported alias\fRes. An exported alias
 160 is defined for scripts invoked by \fIname\fR. The exit status is non-zero if a
 161 \fIname\fR is specified, but no value, and no alias has been defined for the
 162 \fIname\fR.
 163 .sp
 164 .LP
 165 The \fBalias\fRs specified by the list of \fIname\fRs can be removed from the
 166 \fBalias\fR list with \fBunalias\fR.
 167 .SS "\fBksh93\fR"
 168 .sp
 169 .LP
 170 \fBalias\fR creates or redefines alias definitions or writes the existing alias
 171 definitions to standard output.
 172 .sp
 173 .LP
 174 An alias definition provides a string value that replaces a command name when
 175 the command is read. Alias names can contain any printable character that is
 176 not special to the shell. If an alias value ends in a SPACE or TAB, the word
 177 following the command name the alias replaces is also checked to see whether it
 178 is an alias.
 179 .sp
 180 .LP
 181 If no names are specified, the names and values of all aliases are written to
 182 standard output. Otherwise, for each name that is specified, and
 183 \fB=\fR\fIvalue\fR is not specified, the current value of the alias
 184 corresponding to name is written to standard output. If \fB=\fR\fIvalue\fR is
 185 specified, the alias name is created or redefined.
 186 .sp
 187 .LP
 188 \fBalias\fR is built-in to the shell as a declaration command so that field
 189 splitting and pathname expansion are not performed on the arguments. Tilde
 190 expansion occurs on \fIvalue\fR. An alias definition only affects scripts read
 191 by the current shell environment. It does not affect scripts run by this shell.
 192 .sp
 193 .LP
 194 \fBunalias\fR removes the definition of each named alias from the current shell
 195 execution environment, or all aliases if \fB-a\fR is specified. It does not
 196 affect any commands that have already been read and subsequently executed.
 197 .SH OPTIONS
 198 .sp
 199 .LP
 200 The following option is supported by \fBunalias\fR:
 201 .sp
 202 .ne 2
 203 .na
 204 \fB\fB-a\fR\fR
 205 .ad
 206 .RS 6n
 207 Removes all alias definitions from the current shell execution environment.
 208 .RE
 209 
 210 .SS "\fBksh\fR"
 211 .sp
 212 .LP
 213 The following option is supported by \fBalias\fR:
 214 .sp
 215 .ne 2
 216 .na
 217 \fB\fB-t\fR\fR
 218 .ad
 219 .RS 6n
 220 Sets and lists tracked aliases.
 221 .RE
 222 
 223 .SS "\fBksh93\fR"
 224 .sp
 225 .LP
 226 The following options are supported by \fBalias\fR:
 227 .sp
 228 .ne 2
 229 .na
 230 \fB\fB-p\fR\fR
 231 .ad
 232 .RS 6n
 233 Causes the output to be in the form of \fBalias\fR commands that can be used as
 234 input to the shell to recreate the current aliases.
 235 .RE
 236 
 237 .sp
 238 .ne 2
 239 .na
 240 \fB\fB-t\fR\fR
 241 .ad
 242 .RS 6n
 243 Specifies tracked aliases.
 244 .sp
 245 Tracked aliases connect a command name to the command's pathname, and are reset
 246 when the \fBPATH\fR variable is unset. The tracked aliases feature is now
 247 obsolete.
 248 .RE
 249 
 250 .sp
 251 .ne 2
 252 .na
 253 \fB\fB-x\fR\fR
 254 .ad
 255 .RS 6n
 256 Ignored, this option is obsolete.
 257 .RE
 258 
 259 .sp
 260 .LP
 261 The following option is supported by \fBunalias\fR:
 262 .sp
 263 .ne 2
 264 .na
 265 \fB\fB-a\fR\fR
 266 .ad
 267 .RS 6n
 268 Causes all alias definitions to be removed. \fIname\fR operands are optional
 269 and ignored if specified.
 270 .RE
 271 
 272 .SH OPERANDS
 273 .sp
 274 .LP
 275 The following operands are supported:
 276 .SS "\fBalias\fR"
 277 .sp
 278 .ne 2
 279 .na
 280 \fB\fIalias-name\fR\fR
 281 .ad
 282 .RS 14n
 283 Write the alias definition to standard output.
 284 .RE
 285 
 286 .SS "\fBunalias\fR"
 287 .sp
 288 .ne 2
 289 .na
 290 \fB\fIalias-name\fR\fR
 291 .ad
 292 .RS 21n
 293 The name of an alias to be removed.
 294 .RE
 295 
 296 .sp
 297 .ne 2
 298 .na
 299 \fB\fIalias-name\fR\fB=\fR\fIstring\fR\fR
 300 .ad
 301 .RS 21n
 302 Assign the value of \fIstring\fR to the alias \fIalias-name\fR.
 303 .RE
 304 
 305 .sp
 306 .LP
 307 If no operands are specified, all alias definitions are written to standard
 308 output.
 309 .SH OUTPUT
 310 .sp
 311 .LP
 312 The format for displaying aliases (when no operands or only \fIname\fR operands
 313 are specified) is:
 314 .sp
 315 .in +2
 316 .nf
 317 "%s=%s\en" \fIname\fR, \fIvalue\fR
 318 .fi
 319 .in -2
 320 .sp
 321 
 322 .sp
 323 .LP
 324 The \fIvalue\fR string is written with appropriate quoting so that it is
 325 suitable for reinput to the shell.
 326 .SH EXAMPLES
 327 .LP
 328 \fBExample 1 \fRModifying a Command's Output
 329 .sp
 330 .LP
 331 This example specifies that the output of the \fBls\fR utility is columnated
 332 and more annotated:
 333 
 334 .sp
 335 .in +2
 336 .nf
 337 example% \fBalias ls="ls \(miCF"\fR
 338 .fi
 339 .in -2
 340 .sp
 341 
 342 .LP
 343 \fBExample 2 \fRRepeating Previous Entries in the Command History File
 344 .sp
 345 .LP
 346 This example creates a simple "redo" command to repeat previous entries in the
 347 command history file:
 348 
 349 .sp
 350 .in +2
 351 .nf
 352 example% \fBalias r='fc \(mis'\fR
 353 .fi
 354 .in -2
 355 .sp
 356 
 357 .LP
 358 \fBExample 3 \fRSpecifying a Command's Output Options
 359 .sp
 360 .LP
 361 This example provides that the \fBdu\fR utility summarize disk output in units
 362 of 1024 bytes:
 363 
 364 .sp
 365 .in +2
 366 .nf
 367 example% \fBalias du=du \(mik\fR
 368 .fi
 369 .in -2
 370 .sp
 371 
 372 .LP
 373 \fBExample 4 \fRDealing with an Argument That is an Alias Name
 374 .sp
 375 .LP
 376 This example sets up the \fBnohup\fR utility so that it can deal with an
 377 argument that is an alias name:
 378 
 379 .sp
 380 .in +2
 381 .nf
 382 example% \fBalias nohup="nohup "\fR
 383 .fi
 384 .in -2
 385 .sp
 386 
 387 .SH ENVIRONMENT VARIABLES
 388 .sp
 389 .LP
 390 See \fBenviron\fR(5) for descriptions of the following environment variables
 391 that affect the execution of \fBalias\fR and \fBunalias\fR: \fBLANG\fR,
 392 \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 393 .SH EXIT STATUS
 394 .sp
 395 .LP
 396 The following exit values are returned:
 397 .sp
 398 .ne 2
 399 .na
 400 \fB\fB0\fR\fR
 401 .ad
 402 .RS 5n
 403 Successful completion.
 404 .RE
 405 
 406 .SS "\fBalias\fR"
 407 .sp
 408 .ne 2
 409 .na
 410 \fB\fB>0\fR\fR
 411 .ad
 412 .RS 6n
 413 One of the \fIalias-name\fR operands specified did not have an alias
 414 definition, or an error occurred.
 415 .RE
 416 
 417 .SS "\fBunalias\fR"
 418 .sp
 419 .ne 2
 420 .na
 421 \fB\fB>0\fR\fR
 422 .ad
 423 .RS 6n
 424 One of the \fIalias-name\fR operands specified did not represent a valid alias
 425 definition, or an error occurred.
 426 .RE
 427 
 428 .SH ATTRIBUTES
 429 .sp
 430 .LP
 431 See \fBattributes\fR(5) for descriptions of the following attributes:
 432 .SS "\fBcsh, ksh\fR"
 433 .sp
 434 
 435 .sp
 436 .TS
 437 box;
 438 c | c
 439 l | l .
 440 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 441 _
 442 Interface Stability     Committed
 443 _
 444 Standard        See \fBstandards\fR(5).
 445 .TE
 446 
 447 .SS "\fBksh93\fR"
 448 .sp
 449 
 450 .sp
 451 .TS
 452 box;
 453 c | c
 454 l | l .
 455 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 456 _
 457 Interface Stability     Uncommitted
 458 .TE
 459 
 460 .SH SEE ALSO
 461 .sp
 462 .LP
 463 \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBshell_builtins\fR(1),
 464 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)