summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/alias.1
blob: acb1b25ba840864e13b520dd56679c181e98942b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document.  The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\"
.TH ALIAS 1 "Apr 8, 2008"
.SH NAME
alias, unalias \- create or remove a pseudonym or shorthand for a command or
series of commands
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/alias\fR [\fIalias-name\fR[= \fIstring\fR...]]
.fi

.LP
.nf
\fB/usr/bin/unalias\fR \fIalias-name\fR...
.fi

.LP
.nf
\fB/usr/bin/unalias\fR \fB-a\fR
.fi

.SS "\fBcsh\fR"
.LP
.nf
\fBalias\fR [\fIname\fR [\fIdef\fR]]
.fi

.LP
.nf
\fBunalias\fR \fIpattern\fR
.fi

.SS "\fBksh\fR"
.LP
.nf
\fBalias\fR [\fB-tx\fR] [\fIname\fR[= \fIvalue\fR]...]
.fi

.LP
.nf
\fBunalias\fR \fIname\fR...
.fi

.LP
.nf
\fBunalias\fR [\fB-a\fR]
.fi

.SS "\fBksh93\fR"
.LP
.nf
\fBalias\fR [\fB-ptx\fR] [\fIname\fR[= \fIvalue\fR]...]
.fi

.LP
.nf
\fBunalias\fR [\fB-a\fR] [\fIname\fR...]
.fi

.SH DESCRIPTION
.sp
.LP
The \fBalias\fR and \fBunalias\fR utilities create or remove a pseudonym or
shorthand term for a command or series of commands, with different
functionality in the C-shell and Korn shell environments.
.SS "\fB/usr/bin/alias\fR"
.sp
.LP
The \fBalias\fR utility creates or redefines alias definitions or writes the
values of existing alias definitions to standard output. An alias definition
provides a string value that replaces a command name when it is encountered.
.sp
.LP
An alias definition affects the current shell execution environment and the
execution environments of the subshells of the current shell. When used as
specified by this document, the alias definition does not affect the parent
process of the current shell nor any utility environment invoked by the shell.
.SS "\fB/usr/bin/unalias\fR"
.sp
.LP
The \fBunalias\fR utility removes the definition for each alias name specified.
The aliases are removed from the current shell execution environment. The
\fB-a\fR option removes all alias definitions from the current execution
environment.
.SS "\fBcsh\fR"
.sp
.LP
\fBalias\fR assigns \fIdef\fR to the alias \fIname\fR. The assigned \fIdef\fR
is a list of words that can contain escaped history-substitution metasyntax.
\fIname\fR is not allowed to be \fBalias\fR or \fBunalias\fR. If \fIdef\fR is
omitted, the alias \fIname\fR is displayed along with its current definition.
If both \fIname\fR and \fIdef\fR are omitted, all aliases are displayed.
.sp
.LP
Because of implementation restrictions, an alias definition must have been
entered on a previous command line before it can be used.
.sp
.LP
\fBunalias\fR discards aliases that match (filename substitution)
\fIpattern\fR. All aliases can be removed by `\fBunalias *\fR'.
.SS "\fBksh\fR"
.sp
.LP
\fBalias\fR with no arguments prints the list of aliases in the form
\fIname=value\fR on standard output. An \fBalias\fR is defined for each name
whose \fIvalue\fR is specified. A trailing space in \fIvalue\fR causes the next
word to be checked for alias substitution. The \fB-t\fR flag is used to set and
list tracked aliases. The value of a tracked alias is the full pathname
corresponding to the specified \fIname\fR. The value becomes undefined when the
value of \fBPATH\fR is reset but the aliases remained tracked. Without the
\fB-t\fR flag, for each \fIname\fR in the argument list for which no
\fIvalue\fR is specified, the name and value of the alias is printed. The
\fB-x\fR flag is used to set or print \fIexported alias\fRes. An exported alias
is defined for scripts invoked by \fIname\fR. The exit status is non-zero if a
\fIname\fR is specified, but no value, and no alias has been defined for the
\fIname\fR.
.sp
.LP
The \fBalias\fRs specified by the list of \fIname\fRs can be removed from the
\fBalias\fR list with \fBunalias\fR.
.SS "\fBksh93\fR"
.sp
.LP
\fBalias\fR creates or redefines alias definitions or writes the existing alias
definitions to standard output.
.sp
.LP
An alias definition provides a string value that replaces a command name when
the command is read. Alias names can contain any printable character that is
not special to the shell. If an alias value ends in a SPACE or TAB, the word
following the command name the alias replaces is also checked to see whether it
is an alias.
.sp
.LP
If no names are specified, the names and values of all aliases are written to
standard output. Otherwise, for each name that is specified, and
\fB=\fR\fIvalue\fR is not specified, the current value of the alias
corresponding to name is written to standard output. If \fB=\fR\fIvalue\fR is
specified, the alias name is created or redefined.
.sp
.LP
\fBalias\fR is built-in to the shell as a declaration command so that field
splitting and pathname expansion are not performed on the arguments. Tilde
expansion occurs on \fIvalue\fR. An alias definition only affects scripts read
by the current shell environment. It does not affect scripts run by this shell.
.sp
.LP
\fBunalias\fR removes the definition of each named alias from the current shell
execution environment, or all aliases if \fB-a\fR is specified. It does not
affect any commands that have already been read and subsequently executed.
.SH OPTIONS
.sp
.LP
The following option is supported by \fBunalias\fR:
.sp
.ne 2
.na
\fB\fB-a\fR\fR
.ad
.RS 6n
Removes all alias definitions from the current shell execution environment.
.RE

.SS "\fBksh\fR"
.sp
.LP
The following option is supported by \fBalias\fR:
.sp
.ne 2
.na
\fB\fB-t\fR\fR
.ad
.RS 6n
Sets and lists tracked aliases.
.RE

.SS "\fBksh93\fR"
.sp
.LP
The following options are supported by \fBalias\fR:
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 6n
Causes the output to be in the form of \fBalias\fR commands that can be used as
input to the shell to recreate the current aliases.
.RE

.sp
.ne 2
.na
\fB\fB-t\fR\fR
.ad
.RS 6n
Specifies tracked aliases.
.sp
Tracked aliases connect a command name to the command's pathname, and are reset
when the \fBPATH\fR variable is unset. The tracked aliases feature is now
obsolete.
.RE

.sp
.ne 2
.na
\fB\fB-x\fR\fR
.ad
.RS 6n
Ignored, this option is obsolete.
.RE

.sp
.LP
The following option is supported by \fBunalias\fR:
.sp
.ne 2
.na
\fB\fB-a\fR\fR
.ad
.RS 6n
Causes all alias definitions to be removed. \fIname\fR operands are optional
and ignored if specified.
.RE

.SH OPERANDS
.sp
.LP
The following operands are supported:
.SS "\fBalias\fR"
.sp
.ne 2
.na
\fB\fIalias-name\fR\fR
.ad
.RS 14n
Write the alias definition to standard output.
.RE

.SS "\fBunalias\fR"
.sp
.ne 2
.na
\fB\fIalias-name\fR\fR
.ad
.RS 21n
The name of an alias to be removed.
.RE

.sp
.ne 2
.na
\fB\fIalias-name\fR\fB=\fR\fIstring\fR\fR
.ad
.RS 21n
Assign the value of \fIstring\fR to the alias \fIalias-name\fR.
.RE

.sp
.LP
If no operands are specified, all alias definitions are written to standard
output.
.SH OUTPUT
.sp
.LP
The format for displaying aliases (when no operands or only \fIname\fR operands
are specified) is:
.sp
.in +2
.nf
"%s=%s\en" \fIname\fR, \fIvalue\fR
.fi
.in -2
.sp

.sp
.LP
The \fIvalue\fR string is written with appropriate quoting so that it is
suitable for reinput to the shell.
.SH EXAMPLES
.LP
\fBExample 1 \fRModifying a Command's Output
.sp
.LP
This example specifies that the output of the \fBls\fR utility is columnated
and more annotated:

.sp
.in +2
.nf
example% \fBalias ls="ls \(miCF"\fR
.fi
.in -2
.sp

.LP
\fBExample 2 \fRRepeating Previous Entries in the Command History File
.sp
.LP
This example creates a simple "redo" command to repeat previous entries in the
command history file:

.sp
.in +2
.nf
example% \fBalias r='fc \(mis'\fR
.fi
.in -2
.sp

.LP
\fBExample 3 \fRSpecifying a Command's Output Options
.sp
.LP
This example provides that the \fBdu\fR utility summarize disk output in units
of 1024 bytes:

.sp
.in +2
.nf
example% \fBalias du=du \(mik\fR
.fi
.in -2
.sp

.LP
\fBExample 4 \fRDealing with an Argument That is an Alias Name
.sp
.LP
This example sets up the \fBnohup\fR utility so that it can deal with an
argument that is an alias name:

.sp
.in +2
.nf
example% \fBalias nohup="nohup "\fR
.fi
.in -2
.sp

.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBalias\fR and \fBunalias\fR: \fBLANG\fR,
\fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 5n
Successful completion.
.RE

.SS "\fBalias\fR"
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
One of the \fIalias-name\fR operands specified did not have an alias
definition, or an error occurred.
.RE

.SS "\fBunalias\fR"
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
One of the \fIalias-name\fR operands specified did not represent a valid alias
definition, or an error occurred.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.SS "\fBcsh, ksh\fR"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
Standard	See \fBstandards\fR(7).
.TE

.SS "\fBksh93\fR"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Uncommitted
.TE

.SH SEE ALSO
.sp
.LP
.BR csh (1),
.BR ksh (1),
.BR ksh93 (1),
.BR shell_builtins (1),
.BR attributes (7),
.BR environ (7),
.BR standards (7)