-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
15363 lines (14687 loc) · 756 KB
/
index.html
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This text is a brief description of the features that are present in
the Bash shell (version 4.4, 7 September 2016).
This is Edition 4.4, last updated 7 September 2016,
of The GNU Bash Reference Manual,
for Bash, Version 4.4.
Copyright (C) 1988-2016 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled
"GNU Free Documentation License". -->
<!-- Created by GNU Texinfo 6.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Bash Reference Manual</title>
<meta name="description" content="Bash Reference Manual">
<meta name="keywords" content="Bash Reference Manual">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="#Top" rel="start" title="Top">
<link href="#Indexes" rel="index" title="Indexes">
<link href="#SEC_Contents" rel="contents" title="Table of Contents">
<link href="dir.html#Top" rel="up" title="(dir)">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en">
<h1 class="settitle" align="center">Bash Reference Manual</h1>
<a name="SEC_Contents"></a>
<h2 class="contents-heading">Table of Contents</h2>
<div class="contents">
<ul class="no-bullet">
<li><a name="toc-Introduction-1" href="#Introduction">1 Introduction</a>
<ul class="no-bullet">
<li><a name="toc-What-is-Bash_003f-1" href="#What-is-Bash_003f">1.1 What is Bash?</a></li>
<li><a name="toc-What-is-a-shell_003f-1" href="#What-is-a-shell_003f">1.2 What is a shell?</a></li>
</ul></li>
<li><a name="toc-Definitions-1" href="#Definitions">2 Definitions</a></li>
<li><a name="toc-Basic-Shell-Features-1" href="#Basic-Shell-Features">3 Basic Shell Features</a>
<ul class="no-bullet">
<li><a name="toc-Shell-Syntax-1" href="#Shell-Syntax">3.1 Shell Syntax</a>
<ul class="no-bullet">
<li><a name="toc-Shell-Operation-1" href="#Shell-Operation">3.1.1 Shell Operation</a></li>
<li><a name="toc-Quoting-1" href="#Quoting">3.1.2 Quoting</a>
<ul class="no-bullet">
<li><a name="toc-Escape-Character-1" href="#Escape-Character">3.1.2.1 Escape Character</a></li>
<li><a name="toc-Single-Quotes-1" href="#Single-Quotes">3.1.2.2 Single Quotes</a></li>
<li><a name="toc-Double-Quotes-1" href="#Double-Quotes">3.1.2.3 Double Quotes</a></li>
<li><a name="toc-ANSI_002dC-Quoting-1" href="#ANSI_002dC-Quoting">3.1.2.4 ANSI-C Quoting</a></li>
<li><a name="toc-Locale_002dSpecific-Translation" href="#Locale-Translation">3.1.2.5 Locale-Specific Translation</a></li>
</ul></li>
<li><a name="toc-Comments-1" href="#Comments">3.1.3 Comments</a></li>
</ul></li>
<li><a name="toc-Shell-Commands-1" href="#Shell-Commands">3.2 Shell Commands</a>
<ul class="no-bullet">
<li><a name="toc-Simple-Commands-1" href="#Simple-Commands">3.2.1 Simple Commands</a></li>
<li><a name="toc-Pipelines-1" href="#Pipelines">3.2.2 Pipelines</a></li>
<li><a name="toc-Lists-of-Commands" href="#Lists">3.2.3 Lists of Commands</a></li>
<li><a name="toc-Compound-Commands-1" href="#Compound-Commands">3.2.4 Compound Commands</a>
<ul class="no-bullet">
<li><a name="toc-Looping-Constructs-1" href="#Looping-Constructs">3.2.4.1 Looping Constructs</a></li>
<li><a name="toc-Conditional-Constructs-1" href="#Conditional-Constructs">3.2.4.2 Conditional Constructs</a></li>
<li><a name="toc-Grouping-Commands" href="#Command-Grouping">3.2.4.3 Grouping Commands</a></li>
</ul></li>
<li><a name="toc-Coprocesses-1" href="#Coprocesses">3.2.5 Coprocesses</a></li>
<li><a name="toc-GNU-Parallel-1" href="#GNU-Parallel">3.2.6 GNU Parallel</a></li>
</ul></li>
<li><a name="toc-Shell-Functions-1" href="#Shell-Functions">3.3 Shell Functions</a></li>
<li><a name="toc-Shell-Parameters-1" href="#Shell-Parameters">3.4 Shell Parameters</a>
<ul class="no-bullet">
<li><a name="toc-Positional-Parameters-1" href="#Positional-Parameters">3.4.1 Positional Parameters</a></li>
<li><a name="toc-Special-Parameters-1" href="#Special-Parameters">3.4.2 Special Parameters</a></li>
</ul></li>
<li><a name="toc-Shell-Expansions-1" href="#Shell-Expansions">3.5 Shell Expansions</a>
<ul class="no-bullet">
<li><a name="toc-Brace-Expansion-1" href="#Brace-Expansion">3.5.1 Brace Expansion</a></li>
<li><a name="toc-Tilde-Expansion-1" href="#Tilde-Expansion">3.5.2 Tilde Expansion</a></li>
<li><a name="toc-Shell-Parameter-Expansion-1" href="#Shell-Parameter-Expansion">3.5.3 Shell Parameter Expansion</a></li>
<li><a name="toc-Command-Substitution-1" href="#Command-Substitution">3.5.4 Command Substitution</a></li>
<li><a name="toc-Arithmetic-Expansion-1" href="#Arithmetic-Expansion">3.5.5 Arithmetic Expansion</a></li>
<li><a name="toc-Process-Substitution-1" href="#Process-Substitution">3.5.6 Process Substitution</a></li>
<li><a name="toc-Word-Splitting-1" href="#Word-Splitting">3.5.7 Word Splitting</a></li>
<li><a name="toc-Filename-Expansion-1" href="#Filename-Expansion">3.5.8 Filename Expansion</a>
<ul class="no-bullet">
<li><a name="toc-Pattern-Matching-1" href="#Pattern-Matching">3.5.8.1 Pattern Matching</a></li>
</ul></li>
<li><a name="toc-Quote-Removal-1" href="#Quote-Removal">3.5.9 Quote Removal</a></li>
</ul></li>
<li><a name="toc-Redirections-1" href="#Redirections">3.6 Redirections</a>
<ul class="no-bullet">
<li><a name="toc-Redirecting-Input" href="#Redirecting-Input">3.6.1 Redirecting Input</a></li>
<li><a name="toc-Redirecting-Output" href="#Redirecting-Output">3.6.2 Redirecting Output</a></li>
<li><a name="toc-Appending-Redirected-Output" href="#Appending-Redirected-Output">3.6.3 Appending Redirected Output</a></li>
<li><a name="toc-Redirecting-Standard-Output-and-Standard-Error" href="#Redirecting-Standard-Output-and-Standard-Error">3.6.4 Redirecting Standard Output and Standard Error</a></li>
<li><a name="toc-Appending-Standard-Output-and-Standard-Error" href="#Appending-Standard-Output-and-Standard-Error">3.6.5 Appending Standard Output and Standard Error</a></li>
<li><a name="toc-Here-Documents" href="#Here-Documents">3.6.6 Here Documents</a></li>
<li><a name="toc-Here-Strings" href="#Here-Strings">3.6.7 Here Strings</a></li>
<li><a name="toc-Duplicating-File-Descriptors" href="#Duplicating-File-Descriptors">3.6.8 Duplicating File Descriptors</a></li>
<li><a name="toc-Moving-File-Descriptors" href="#Moving-File-Descriptors">3.6.9 Moving File Descriptors</a></li>
<li><a name="toc-Opening-File-Descriptors-for-Reading-and-Writing" href="#Opening-File-Descriptors-for-Reading-and-Writing">3.6.10 Opening File Descriptors for Reading and Writing</a></li>
</ul></li>
<li><a name="toc-Executing-Commands-1" href="#Executing-Commands">3.7 Executing Commands</a>
<ul class="no-bullet">
<li><a name="toc-Simple-Command-Expansion-1" href="#Simple-Command-Expansion">3.7.1 Simple Command Expansion</a></li>
<li><a name="toc-Command-Search-and-Execution-1" href="#Command-Search-and-Execution">3.7.2 Command Search and Execution</a></li>
<li><a name="toc-Command-Execution-Environment-1" href="#Command-Execution-Environment">3.7.3 Command Execution Environment</a></li>
<li><a name="toc-Environment-1" href="#Environment">3.7.4 Environment</a></li>
<li><a name="toc-Exit-Status-1" href="#Exit-Status">3.7.5 Exit Status</a></li>
<li><a name="toc-Signals-1" href="#Signals">3.7.6 Signals</a></li>
</ul></li>
<li><a name="toc-Shell-Scripts-1" href="#Shell-Scripts">3.8 Shell Scripts</a></li>
</ul></li>
<li><a name="toc-Shell-Builtin-Commands-1" href="#Shell-Builtin-Commands">4 Shell Builtin Commands</a>
<ul class="no-bullet">
<li><a name="toc-Bourne-Shell-Builtins-1" href="#Bourne-Shell-Builtins">4.1 Bourne Shell Builtins</a></li>
<li><a name="toc-Bash-Builtin-Commands" href="#Bash-Builtins">4.2 Bash Builtin Commands</a></li>
<li><a name="toc-Modifying-Shell-Behavior-1" href="#Modifying-Shell-Behavior">4.3 Modifying Shell Behavior</a>
<ul class="no-bullet">
<li><a name="toc-The-Set-Builtin-1" href="#The-Set-Builtin">4.3.1 The Set Builtin</a></li>
<li><a name="toc-The-Shopt-Builtin-1" href="#The-Shopt-Builtin">4.3.2 The Shopt Builtin</a></li>
</ul></li>
<li><a name="toc-Special-Builtins-1" href="#Special-Builtins">4.4 Special Builtins</a></li>
</ul></li>
<li><a name="toc-Shell-Variables-1" href="#Shell-Variables">5 Shell Variables</a>
<ul class="no-bullet">
<li><a name="toc-Bourne-Shell-Variables-1" href="#Bourne-Shell-Variables">5.1 Bourne Shell Variables</a></li>
<li><a name="toc-Bash-Variables-1" href="#Bash-Variables">5.2 Bash Variables</a></li>
</ul></li>
<li><a name="toc-Bash-Features-2" href="#Bash-Features">6 Bash Features</a>
<ul class="no-bullet">
<li><a name="toc-Invoking-Bash-1" href="#Invoking-Bash">6.1 Invoking Bash</a></li>
<li><a name="toc-Bash-Startup-Files-1" href="#Bash-Startup-Files">6.2 Bash Startup Files</a></li>
<li><a name="toc-Interactive-Shells-1" href="#Interactive-Shells">6.3 Interactive Shells</a>
<ul class="no-bullet">
<li><a name="toc-What-is-an-Interactive-Shell_003f-1" href="#What-is-an-Interactive-Shell_003f">6.3.1 What is an Interactive Shell?</a></li>
<li><a name="toc-Is-this-Shell-Interactive_003f-1" href="#Is-this-Shell-Interactive_003f">6.3.2 Is this Shell Interactive?</a></li>
<li><a name="toc-Interactive-Shell-Behavior-1" href="#Interactive-Shell-Behavior">6.3.3 Interactive Shell Behavior</a></li>
</ul></li>
<li><a name="toc-Bash-Conditional-Expressions-1" href="#Bash-Conditional-Expressions">6.4 Bash Conditional Expressions</a></li>
<li><a name="toc-Shell-Arithmetic-1" href="#Shell-Arithmetic">6.5 Shell Arithmetic</a></li>
<li><a name="toc-Aliases-1" href="#Aliases">6.6 Aliases</a></li>
<li><a name="toc-Arrays-1" href="#Arrays">6.7 Arrays</a></li>
<li><a name="toc-The-Directory-Stack-1" href="#The-Directory-Stack">6.8 The Directory Stack</a>
<ul class="no-bullet">
<li><a name="toc-Directory-Stack-Builtins-1" href="#Directory-Stack-Builtins">6.8.1 Directory Stack Builtins</a></li>
</ul></li>
<li><a name="toc-Controlling-the-Prompt-1" href="#Controlling-the-Prompt">6.9 Controlling the Prompt</a></li>
<li><a name="toc-The-Restricted-Shell-1" href="#The-Restricted-Shell">6.10 The Restricted Shell</a></li>
<li><a name="toc-Bash-POSIX-Mode-1" href="#Bash-POSIX-Mode">6.11 Bash POSIX Mode</a></li>
</ul></li>
<li><a name="toc-Job-Control-1" href="#Job-Control">7 Job Control</a>
<ul class="no-bullet">
<li><a name="toc-Job-Control-Basics-1" href="#Job-Control-Basics">7.1 Job Control Basics</a></li>
<li><a name="toc-Job-Control-Builtins-1" href="#Job-Control-Builtins">7.2 Job Control Builtins</a></li>
<li><a name="toc-Job-Control-Variables-1" href="#Job-Control-Variables">7.3 Job Control Variables</a></li>
</ul></li>
<li><a name="toc-Command-Line-Editing-1" href="#Command-Line-Editing">8 Command Line Editing</a>
<ul class="no-bullet">
<li><a name="toc-Introduction-to-Line-Editing" href="#Introduction-and-Notation">8.1 Introduction to Line Editing</a></li>
<li><a name="toc-Readline-Interaction-1" href="#Readline-Interaction">8.2 Readline Interaction</a>
<ul class="no-bullet">
<li><a name="toc-Readline-Bare-Essentials-1" href="#Readline-Bare-Essentials">8.2.1 Readline Bare Essentials</a></li>
<li><a name="toc-Readline-Movement-Commands-1" href="#Readline-Movement-Commands">8.2.2 Readline Movement Commands</a></li>
<li><a name="toc-Readline-Killing-Commands-1" href="#Readline-Killing-Commands">8.2.3 Readline Killing Commands</a></li>
<li><a name="toc-Readline-Arguments-1" href="#Readline-Arguments">8.2.4 Readline Arguments</a></li>
<li><a name="toc-Searching-for-Commands-in-the-History" href="#Searching">8.2.5 Searching for Commands in the History</a></li>
</ul></li>
<li><a name="toc-Readline-Init-File-1" href="#Readline-Init-File">8.3 Readline Init File</a>
<ul class="no-bullet">
<li><a name="toc-Readline-Init-File-Syntax-1" href="#Readline-Init-File-Syntax">8.3.1 Readline Init File Syntax</a></li>
<li><a name="toc-Conditional-Init-Constructs-1" href="#Conditional-Init-Constructs">8.3.2 Conditional Init Constructs</a></li>
<li><a name="toc-Sample-Init-File-1" href="#Sample-Init-File">8.3.3 Sample Init File</a></li>
</ul></li>
<li><a name="toc-Bindable-Readline-Commands-1" href="#Bindable-Readline-Commands">8.4 Bindable Readline Commands</a>
<ul class="no-bullet">
<li><a name="toc-Commands-For-Moving-1" href="#Commands-For-Moving">8.4.1 Commands For Moving</a></li>
<li><a name="toc-Commands-For-Manipulating-The-History" href="#Commands-For-History">8.4.2 Commands For Manipulating The History</a></li>
<li><a name="toc-Commands-For-Changing-Text" href="#Commands-For-Text">8.4.3 Commands For Changing Text</a></li>
<li><a name="toc-Killing-And-Yanking" href="#Commands-For-Killing">8.4.4 Killing And Yanking</a></li>
<li><a name="toc-Specifying-Numeric-Arguments" href="#Numeric-Arguments">8.4.5 Specifying Numeric Arguments</a></li>
<li><a name="toc-Letting-Readline-Type-For-You" href="#Commands-For-Completion">8.4.6 Letting Readline Type For You</a></li>
<li><a name="toc-Keyboard-Macros-1" href="#Keyboard-Macros">8.4.7 Keyboard Macros</a></li>
<li><a name="toc-Some-Miscellaneous-Commands" href="#Miscellaneous-Commands">8.4.8 Some Miscellaneous Commands</a></li>
</ul></li>
<li><a name="toc-Readline-vi-Mode-1" href="#Readline-vi-Mode">8.5 Readline vi Mode</a></li>
<li><a name="toc-Programmable-Completion-1" href="#Programmable-Completion">8.6 Programmable Completion</a></li>
<li><a name="toc-Programmable-Completion-Builtins-1" href="#Programmable-Completion-Builtins">8.7 Programmable Completion Builtins</a></li>
<li><a name="toc-A-Programmable-Completion-Example-1" href="#A-Programmable-Completion-Example">8.8 A Programmable Completion Example</a></li>
</ul></li>
<li><a name="toc-Using-History-Interactively-1" href="#Using-History-Interactively">9 Using History Interactively</a>
<ul class="no-bullet">
<li><a name="toc-Bash-History-Facilities-1" href="#Bash-History-Facilities">9.1 Bash History Facilities</a></li>
<li><a name="toc-Bash-History-Builtins-1" href="#Bash-History-Builtins">9.2 Bash History Builtins</a></li>
<li><a name="toc-History-Expansion" href="#History-Interaction">9.3 History Expansion</a>
<ul class="no-bullet">
<li><a name="toc-Event-Designators-1" href="#Event-Designators">9.3.1 Event Designators</a></li>
<li><a name="toc-Word-Designators-1" href="#Word-Designators">9.3.2 Word Designators</a></li>
<li><a name="toc-Modifiers-1" href="#Modifiers">9.3.3 Modifiers</a></li>
</ul></li>
</ul></li>
<li><a name="toc-Installing-Bash-1" href="#Installing-Bash">10 Installing Bash</a>
<ul class="no-bullet">
<li><a name="toc-Basic-Installation-1" href="#Basic-Installation">10.1 Basic Installation</a></li>
<li><a name="toc-Compilers-and-Options-1" href="#Compilers-and-Options">10.2 Compilers and Options</a></li>
<li><a name="toc-Compiling-For-Multiple-Architectures-1" href="#Compiling-For-Multiple-Architectures">10.3 Compiling For Multiple Architectures</a></li>
<li><a name="toc-Installation-Names-1" href="#Installation-Names">10.4 Installation Names</a></li>
<li><a name="toc-Specifying-the-System-Type-1" href="#Specifying-the-System-Type">10.5 Specifying the System Type</a></li>
<li><a name="toc-Sharing-Defaults-1" href="#Sharing-Defaults">10.6 Sharing Defaults</a></li>
<li><a name="toc-Operation-Controls-1" href="#Operation-Controls">10.7 Operation Controls</a></li>
<li><a name="toc-Optional-Features-1" href="#Optional-Features">10.8 Optional Features</a></li>
</ul></li>
<li><a name="toc-Reporting-Bugs-1" href="#Reporting-Bugs">Appendix A Reporting Bugs</a></li>
<li><a name="toc-Major-Differences-From-The-Bourne-Shell-1" href="#Major-Differences-From-The-Bourne-Shell">Appendix B Major Differences From The Bourne Shell</a>
<ul class="no-bullet">
<li><a name="toc-Implementation-Differences-From-The-SVR4_002e2-Shell" href="#Implementation-Differences-From-The-SVR4_002e2-Shell">B.1 Implementation Differences From The SVR4.2 Shell</a></li>
</ul></li>
<li><a name="toc-GNU-Free-Documentation-License-1" href="#GNU-Free-Documentation-License">Appendix C GNU Free Documentation License</a></li>
<li><a name="toc-Indexes-1" href="#Indexes">Appendix D Indexes</a>
<ul class="no-bullet">
<li><a name="toc-Index-of-Shell-Builtin-Commands" href="#Builtin-Index">D.1 Index of Shell Builtin Commands</a></li>
<li><a name="toc-Index-of-Shell-Reserved-Words" href="#Reserved-Word-Index">D.2 Index of Shell Reserved Words</a></li>
<li><a name="toc-Parameter-and-Variable-Index" href="#Variable-Index">D.3 Parameter and Variable Index</a></li>
<li><a name="toc-Function-Index-1" href="#Function-Index">D.4 Function Index</a></li>
<li><a name="toc-Concept-Index-1" href="#Concept-Index">D.5 Concept Index</a></li>
</ul></li>
</ul>
</div>
<a name="Top"></a>
<div class="header">
<p>
Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Bash-Features-1"></a>
<h1 class="top">Bash Features</h1>
<p>This text is a brief description of the features that are present in
the Bash shell (version 4.4, 7 September 2016).
The Bash home page is <a href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>.
</p>
<p>This is Edition 4.4, last updated 7 September 2016,
of <cite>The GNU Bash Reference Manual</cite>,
for <code>Bash</code>, Version 4.4.
</p>
<p>Bash contains features that appear in other popular shells, and some
features that only appear in Bash. Some of the shells that Bash has
borrowed concepts from are the Bourne Shell (<samp>sh</samp>), the Korn Shell
(<samp>ksh</samp>), and the C-shell (<samp>csh</samp> and its successor,
<samp>tcsh</samp>). The following menu breaks the features up into
categories, noting which features were inspired by other shells and
which are specific to Bash.
</p>
<p>This manual is meant as a brief introduction to features found in
Bash. The Bash manual page should be used as the definitive
reference on shell behavior.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Introduction" accesskey="1">Introduction</a>:</td><td> </td><td align="left" valign="top">An introduction to the shell.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Definitions" accesskey="2">Definitions</a>:</td><td> </td><td align="left" valign="top">Some definitions used in the rest of this
manual.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Basic-Shell-Features" accesskey="3">Basic Shell Features</a>:</td><td> </td><td align="left" valign="top">The shell "building blocks".
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shell-Builtin-Commands" accesskey="4">Shell Builtin Commands</a>:</td><td> </td><td align="left" valign="top">Commands that are a part of the shell.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shell-Variables" accesskey="5">Shell Variables</a>:</td><td> </td><td align="left" valign="top">Variables used or set by Bash.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Bash-Features" accesskey="6">Bash Features</a>:</td><td> </td><td align="left" valign="top">Features found only in Bash.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Job-Control" accesskey="7">Job Control</a>:</td><td> </td><td align="left" valign="top">What job control is and how Bash allows you
to use it.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Command-Line-Editing" accesskey="8">Command Line Editing</a>:</td><td> </td><td align="left" valign="top">Chapter describing the command line
editing features.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Using-History-Interactively" accesskey="9">Using History Interactively</a>:</td><td> </td><td align="left" valign="top">Command History Expansion
</td></tr>
<tr><td align="left" valign="top">• <a href="#Installing-Bash">Installing Bash</a>:</td><td> </td><td align="left" valign="top">How to build and install Bash on your system.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Reporting-Bugs">Reporting Bugs</a>:</td><td> </td><td align="left" valign="top">How to report bugs in Bash.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Major-Differences-From-The-Bourne-Shell">Major Differences From The Bourne Shell</a>:</td><td> </td><td align="left" valign="top">A terse list of the differences
between Bash and historical
versions of /bin/sh.
</td></tr>
<tr><td align="left" valign="top">• <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>:</td><td> </td><td align="left" valign="top">Copying and sharing this documentation.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Indexes">Indexes</a>:</td><td> </td><td align="left" valign="top">Various indexes for this manual.
</td></tr>
</table>
<hr>
<a name="Introduction"></a>
<div class="header">
<p>
Next: <a href="#Definitions" accesskey="n" rel="next">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Introduction-1"></a>
<h2 class="chapter">1 Introduction</h2>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#What-is-Bash_003f" accesskey="1">What is Bash?</a>:</td><td> </td><td align="left" valign="top">A short description of Bash.
</td></tr>
<tr><td align="left" valign="top">• <a href="#What-is-a-shell_003f" accesskey="2">What is a shell?</a>:</td><td> </td><td align="left" valign="top">A brief introduction to shells.
</td></tr>
</table>
<hr>
<a name="What-is-Bash_003f"></a>
<div class="header">
<p>
Next: <a href="#What-is-a-shell_003f" accesskey="n" rel="next">What is a shell?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="What-is-Bash_003f-1"></a>
<h3 class="section">1.1 What is Bash?</h3>
<p>Bash is the shell, or command language interpreter,
for the <small>GNU</small> operating system.
The name is an acronym for the ‘<samp>Bourne-Again SHell</samp>’,
a pun on Stephen Bourne, the author of the direct ancestor of
the current Unix shell <code>sh</code>,
which appeared in the Seventh Edition Bell Labs Research version
of Unix.
</p>
<p>Bash is largely compatible with <code>sh</code> and incorporates useful
features from the Korn shell <code>ksh</code> and the C shell <code>csh</code>.
It is intended to be a conformant implementation of the <small>IEEE</small>
<small>POSIX</small> Shell and Tools portion of the <small>IEEE</small> <small>POSIX</small>
specification (<small>IEEE</small> Standard 1003.1).
It offers functional improvements over <code>sh</code> for both interactive and
programming use.
</p>
<p>While the <small>GNU</small> operating system provides other shells, including
a version of <code>csh</code>, Bash is the default shell.
Like other <small>GNU</small> software, Bash is quite portable. It currently runs
on nearly every version of Unix and a few other operating systems -
independently-supported ports exist for <small>MS-DOS</small>, <small>OS/2</small>,
and Windows platforms.
</p>
<hr>
<a name="What-is-a-shell_003f"></a>
<div class="header">
<p>
Previous: <a href="#What-is-Bash_003f" accesskey="p" rel="prev">What is Bash?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="What-is-a-shell_003f-1"></a>
<h3 class="section">1.2 What is a shell?</h3>
<p>At its base, a shell is simply a macro processor that executes
commands. The term macro processor means functionality where text
and symbols are expanded to create larger expressions.
</p>
<p>A Unix shell is both a command interpreter and a programming
language. As a command interpreter, the shell provides the user
interface to the rich set of <small>GNU</small> utilities. The programming
language features allow these utilities to be combined.
Files containing commands can be created, and become
commands themselves. These new commands have the same status as
system commands in directories such as <samp>/bin</samp>, allowing users
or groups to establish custom environments to automate their common
tasks.
</p>
<p>Shells may be used interactively or non-interactively. In
interactive mode, they accept input typed from the keyboard.
When executing non-interactively, shells execute commands read
from a file.
</p>
<p>A shell allows execution of <small>GNU</small> commands, both synchronously and
asynchronously.
The shell waits for synchronous commands to complete before accepting
more input; asynchronous commands continue to execute in parallel
with the shell while it reads and executes additional commands.
The <em>redirection</em> constructs permit
fine-grained control of the input and output of those commands.
Moreover, the shell allows control over the contents of commands’
environments.
</p>
<p>Shells also provide a small set of built-in
commands (<em>builtins</em>) implementing functionality impossible
or inconvenient to obtain via separate utilities.
For example, <code>cd</code>, <code>break</code>, <code>continue</code>, and
<code>exec</code> cannot be implemented outside of the shell because
they directly manipulate the shell itself.
The <code>history</code>, <code>getopts</code>, <code>kill</code>, or <code>pwd</code>
builtins, among others, could be implemented in separate utilities,
but they are more convenient to use as builtin commands.
All of the shell builtins are described in
subsequent sections.
</p>
<p>While executing commands is essential, most of the power (and
complexity) of shells is due to their embedded programming
languages. Like any high-level language, the shell provides
variables, flow control constructs, quoting, and functions.
</p>
<p>Shells offer features geared specifically for
interactive use rather than to augment the programming language.
These interactive features include job control, command line
editing, command history and aliases. Each of these features is
described in this manual.
</p>
<hr>
<a name="Definitions"></a>
<div class="header">
<p>
Next: <a href="#Basic-Shell-Features" accesskey="n" rel="next">Basic Shell Features</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Definitions-1"></a>
<h2 class="chapter">2 Definitions</h2>
<p>These definitions are used throughout the remainder of this manual.
</p>
<dl compact="compact">
<dt><code>POSIX</code></dt>
<dd><a name="index-POSIX"></a>
<p>A family of open system standards based on Unix. Bash
is primarily concerned with the Shell and Utilities portion of the
<small>POSIX</small> 1003.1 standard.
</p>
</dd>
<dt><code>blank</code></dt>
<dd><p>A space or tab character.
</p>
</dd>
<dt><code>builtin</code></dt>
<dd><a name="index-builtin-1"></a>
<p>A command that is implemented internally by the shell itself, rather
than by an executable program somewhere in the file system.
</p>
</dd>
<dt><code>control operator</code></dt>
<dd><a name="index-control-operator"></a>
<p>A <code>token</code> that performs a control function. It is a <code>newline</code>
or one of the following:
‘<samp>||</samp>’, ‘<samp>&&</samp>’, ‘<samp>&</samp>’, ‘<samp>;</samp>’, ‘<samp>;;</samp>’, ‘<samp>;&</samp>’, ‘<samp>;;&</samp>’,
‘<samp>|</samp>’, ‘<samp>|&</samp>’, ‘<samp>(</samp>’, or ‘<samp>)</samp>’.
</p>
</dd>
<dt><code>exit status</code></dt>
<dd><a name="index-exit-status"></a>
<p>The value returned by a command to its caller. The value is restricted
to eight bits, so the maximum value is 255.
</p>
</dd>
<dt><code>field</code></dt>
<dd><a name="index-field"></a>
<p>A unit of text that is the result of one of the shell expansions. After
expansion, when executing a command, the resulting fields are used as
the command name and arguments.
</p>
</dd>
<dt><code>filename</code></dt>
<dd><a name="index-filename"></a>
<p>A string of characters used to identify a file.
</p>
</dd>
<dt><code>job</code></dt>
<dd><a name="index-job"></a>
<p>A set of processes comprising a pipeline, and any processes descended
from it, that are all in the same process group.
</p>
</dd>
<dt><code>job control</code></dt>
<dd><a name="index-job-control"></a>
<p>A mechanism by which users can selectively stop (suspend) and restart
(resume) execution of processes.
</p>
</dd>
<dt><code>metacharacter</code></dt>
<dd><a name="index-metacharacter"></a>
<p>A character that, when unquoted, separates words. A metacharacter is
a <code>space</code>, <code>tab</code>, <code>newline</code>, or one of the following characters:
‘<samp>|</samp>’, ‘<samp>&</samp>’, ‘<samp>;</samp>’, ‘<samp>(</samp>’, ‘<samp>)</samp>’, ‘<samp><</samp>’, or
‘<samp>></samp>’.
</p>
</dd>
<dt><code>name</code></dt>
<dd><a name="index-name"></a>
<a name="index-identifier"></a>
<p>A <code>word</code> consisting solely of letters, numbers, and underscores,
and beginning with a letter or underscore. <code>Name</code>s are used as
shell variable and function names.
Also referred to as an <code>identifier</code>.
</p>
</dd>
<dt><code>operator</code></dt>
<dd><a name="index-operator_002c-shell"></a>
<p>A <code>control operator</code> or a <code>redirection operator</code>.
See <a href="#Redirections">Redirections</a>, for a list of redirection operators.
Operators contain at least one unquoted <code>metacharacter</code>.
</p>
</dd>
<dt><code>process group</code></dt>
<dd><a name="index-process-group"></a>
<p>A collection of related processes each having the same process
group <small>ID</small>.
</p>
</dd>
<dt><code>process group ID</code></dt>
<dd><a name="index-process-group-ID"></a>
<p>A unique identifier that represents a <code>process group</code>
during its lifetime.
</p>
</dd>
<dt><code>reserved word</code></dt>
<dd><a name="index-reserved-word"></a>
<p>A <code>word</code> that has a special meaning to the shell. Most reserved
words introduce shell flow control constructs, such as <code>for</code> and
<code>while</code>.
</p>
</dd>
<dt><code>return status</code></dt>
<dd><a name="index-return-status"></a>
<p>A synonym for <code>exit status</code>.
</p>
</dd>
<dt><code>signal</code></dt>
<dd><a name="index-signal"></a>
<p>A mechanism by which a process may be notified by the kernel
of an event occurring in the system.
</p>
</dd>
<dt><code>special builtin</code></dt>
<dd><a name="index-special-builtin"></a>
<p>A shell builtin command that has been classified as special by the
<small>POSIX</small> standard.
</p>
</dd>
<dt><code>token</code></dt>
<dd><a name="index-token"></a>
<p>A sequence of characters considered a single unit by the shell.
It is either a <code>word</code> or an <code>operator</code>.
</p>
</dd>
<dt><code>word</code></dt>
<dd><a name="index-word"></a>
<p>A sequence of characters treated as a unit by the shell.
Words may not include unquoted <code>metacharacters</code>.
</p></dd>
</dl>
<hr>
<a name="Basic-Shell-Features"></a>
<div class="header">
<p>
Next: <a href="#Shell-Builtin-Commands" accesskey="n" rel="next">Shell Builtin Commands</a>, Previous: <a href="#Definitions" accesskey="p" rel="prev">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Basic-Shell-Features-1"></a>
<h2 class="chapter">3 Basic Shell Features</h2>
<a name="index-Bourne-shell"></a>
<p>Bash is an acronym for ‘<samp>Bourne-Again SHell</samp>’.
The Bourne shell is
the traditional Unix shell originally written by Stephen Bourne.
All of the Bourne shell builtin commands are available in Bash,
The rules for evaluation and quoting are taken from the <small>POSIX</small>
specification for the ‘standard’ Unix shell.
</p>
<p>This chapter briefly summarizes the shell’s ‘building blocks’:
commands, control structures, shell functions, shell <i>parameters</i>,
shell expansions,
<i>redirections</i>, which are a way to direct input and output from
and to named files, and how the shell executes commands.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Shell-Syntax" accesskey="1">Shell Syntax</a>:</td><td> </td><td align="left" valign="top">What your input means to the shell.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shell-Commands" accesskey="2">Shell Commands</a>:</td><td> </td><td align="left" valign="top">The types of commands you can use.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shell-Functions" accesskey="3">Shell Functions</a>:</td><td> </td><td align="left" valign="top">Grouping commands by name.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shell-Parameters" accesskey="4">Shell Parameters</a>:</td><td> </td><td align="left" valign="top">How the shell stores values.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shell-Expansions" accesskey="5">Shell Expansions</a>:</td><td> </td><td align="left" valign="top">How Bash expands parameters and the various
expansions available.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Redirections" accesskey="6">Redirections</a>:</td><td> </td><td align="left" valign="top">A way to control where input and output go.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Executing-Commands" accesskey="7">Executing Commands</a>:</td><td> </td><td align="left" valign="top">What happens when you run a command.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Shell-Scripts" accesskey="8">Shell Scripts</a>:</td><td> </td><td align="left" valign="top">Executing files of shell commands.
</td></tr>
</table>
<hr>
<a name="Shell-Syntax"></a>
<div class="header">
<p>
Next: <a href="#Shell-Commands" accesskey="n" rel="next">Shell Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Shell-Syntax-1"></a>
<h3 class="section">3.1 Shell Syntax</h3>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Shell-Operation" accesskey="1">Shell Operation</a>:</td><td> </td><td align="left" valign="top">The basic operation of the shell.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Quoting" accesskey="2">Quoting</a>:</td><td> </td><td align="left" valign="top">How to remove the special meaning from characters.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Comments" accesskey="3">Comments</a>:</td><td> </td><td align="left" valign="top">How to specify comments.
</td></tr>
</table>
<p>When the shell reads input, it proceeds through a
sequence of operations. If the input indicates the beginning of a
comment, the shell ignores the comment symbol (‘<samp>#</samp>’), and the rest
of that line.
</p>
<p>Otherwise, roughly speaking, the shell reads its input and
divides the input into words and operators, employing the quoting rules
to select which meanings to assign various words and characters.
</p>
<p>The shell then parses these tokens into commands and other constructs,
removes the special meaning of certain words or characters, expands
others, redirects input and output as needed, executes the specified
command, waits for the command’s exit status, and makes that exit status
available for further inspection or processing.
</p>
<hr>
<a name="Shell-Operation"></a>
<div class="header">
<p>
Next: <a href="#Quoting" accesskey="n" rel="next">Quoting</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Shell-Operation-1"></a>
<h4 class="subsection">3.1.1 Shell Operation</h4>
<p>The following is a brief description of the shell’s operation when it
reads and executes a command. Basically, the shell does the
following:
</p>
<ol>
<li> Reads its input from a file (see <a href="#Shell-Scripts">Shell Scripts</a>), from a string
supplied as an argument to the <samp>-c</samp> invocation option
(see <a href="#Invoking-Bash">Invoking Bash</a>), or from the user’s terminal.
</li><li> Breaks the input into words and operators, obeying the quoting rules
described in <a href="#Quoting">Quoting</a>. These tokens are separated by
<code>metacharacters</code>. Alias expansion is performed by this step
(see <a href="#Aliases">Aliases</a>).
</li><li> Parses the tokens into simple and compound commands
(see <a href="#Shell-Commands">Shell Commands</a>).
</li><li> Performs the various shell expansions (see <a href="#Shell-Expansions">Shell Expansions</a>), breaking
the expanded tokens into lists of filenames (see <a href="#Filename-Expansion">Filename Expansion</a>)
and commands and arguments.
</li><li> Performs any necessary redirections (see <a href="#Redirections">Redirections</a>) and removes
the redirection operators and their operands from the argument list.
</li><li> Executes the command (see <a href="#Executing-Commands">Executing Commands</a>).
</li><li> Optionally waits for the command to complete and collects its exit
status (see <a href="#Exit-Status">Exit Status</a>).
</li></ol>
<hr>
<a name="Quoting"></a>
<div class="header">
<p>
Next: <a href="#Comments" accesskey="n" rel="next">Comments</a>, Previous: <a href="#Shell-Operation" accesskey="p" rel="prev">Shell Operation</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Quoting-1"></a>
<h4 class="subsection">3.1.2 Quoting</h4>
<a name="index-quoting"></a>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Escape-Character" accesskey="1">Escape Character</a>:</td><td> </td><td align="left" valign="top">How to remove the special meaning from a single
character.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Single-Quotes" accesskey="2">Single Quotes</a>:</td><td> </td><td align="left" valign="top">How to inhibit all interpretation of a sequence
of characters.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Double-Quotes" accesskey="3">Double Quotes</a>:</td><td> </td><td align="left" valign="top">How to suppress most of the interpretation of a
sequence of characters.
</td></tr>
<tr><td align="left" valign="top">• <a href="#ANSI_002dC-Quoting" accesskey="4">ANSI-C Quoting</a>:</td><td> </td><td align="left" valign="top">How to expand ANSI-C sequences in quoted strings.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Locale-Translation" accesskey="5">Locale Translation</a>:</td><td> </td><td align="left" valign="top">How to translate strings into different languages.
</td></tr>
</table>
<p>Quoting is used to remove the special meaning of certain
characters or words to the shell. Quoting can be used to
disable special treatment for special characters, to prevent
reserved words from being recognized as such, and to prevent
parameter expansion.
</p>
<p>Each of the shell metacharacters (see <a href="#Definitions">Definitions</a>)
has special meaning to the shell and must be quoted if it is to
represent itself.
When the command history expansion facilities are being used
(see <a href="#History-Interaction">History Interaction</a>), the
<var>history expansion</var> character, usually ‘<samp>!</samp>’, must be quoted
to prevent history expansion. See <a href="#Bash-History-Facilities">Bash History Facilities</a>, for
more details concerning history expansion.
</p>
<p>There are three quoting mechanisms: the
<var>escape character</var>, single quotes, and double quotes.
</p>
<hr>
<a name="Escape-Character"></a>
<div class="header">
<p>
Next: <a href="#Single-Quotes" accesskey="n" rel="next">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Escape-Character-1"></a>
<h4 class="subsubsection">3.1.2.1 Escape Character</h4>
<p>A non-quoted backslash ‘<samp>\</samp>’ is the Bash escape character.
It preserves the literal value of the next character that follows,
with the exception of <code>newline</code>. If a <code>\newline</code> pair
appears, and the backslash itself is not quoted, the <code>\newline</code>
is treated as a line continuation (that is, it is removed from
the input stream and effectively ignored).
</p>
<hr>
<a name="Single-Quotes"></a>
<div class="header">
<p>
Next: <a href="#Double-Quotes" accesskey="n" rel="next">Double Quotes</a>, Previous: <a href="#Escape-Character" accesskey="p" rel="prev">Escape Character</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Single-Quotes-1"></a>
<h4 class="subsubsection">3.1.2.2 Single Quotes</h4>
<p>Enclosing characters in single quotes (‘<samp>'</samp>’) preserves the literal value
of each character within the quotes. A single quote may not occur
between single quotes, even when preceded by a backslash.
</p>
<hr>
<a name="Double-Quotes"></a>
<div class="header">
<p>
Next: <a href="#ANSI_002dC-Quoting" accesskey="n" rel="next">ANSI-C Quoting</a>, Previous: <a href="#Single-Quotes" accesskey="p" rel="prev">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Double-Quotes-1"></a>
<h4 class="subsubsection">3.1.2.3 Double Quotes</h4>
<p>Enclosing characters in double quotes (‘<samp>"</samp>’) preserves the literal value
of all characters within the quotes, with the exception of
‘<samp>$</samp>’, ‘<samp>`</samp>’, ‘<samp>\</samp>’,
and, when history expansion is enabled, ‘<samp>!</samp>’.
When the shell is in
<small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>),
the ‘<samp>!</samp>’ has no special meaning
within double quotes, even when history expansion is enabled.
The characters ‘<samp>$</samp>’ and ‘<samp>`</samp>’
retain their special meaning within double quotes (see <a href="#Shell-Expansions">Shell Expansions</a>).
The backslash retains its special meaning only when followed by one of
the following characters:
‘<samp>$</samp>’, ‘<samp>`</samp>’, ‘<samp>"</samp>’, ‘<samp>\</samp>’, or <code>newline</code>.
Within double quotes, backslashes that are followed by one of these
characters are removed. Backslashes preceding characters without a
special meaning are left unmodified.
A double quote may be quoted within double quotes by preceding it with
a backslash.
If enabled, history expansion will be performed unless an ‘<samp>!</samp>’
appearing in double quotes is escaped using a backslash.
The backslash preceding the ‘<samp>!</samp>’ is not removed.
</p>
<p>The special parameters ‘<samp>*</samp>’ and ‘<samp>@</samp>’ have special meaning
when in double quotes (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>).
</p>
<hr>
<a name="ANSI_002dC-Quoting"></a>
<div class="header">
<p>
Next: <a href="#Locale-Translation" accesskey="n" rel="next">Locale Translation</a>, Previous: <a href="#Double-Quotes" accesskey="p" rel="prev">Double Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="ANSI_002dC-Quoting-1"></a>
<h4 class="subsubsection">3.1.2.4 ANSI-C Quoting</h4>
<a name="index-quoting_002c-ANSI"></a>
<p>Words of the form <code>$'<var>string</var>'</code> are treated specially. The
word expands to <var>string</var>, with backslash-escaped characters replaced
as specified by the ANSI C standard. Backslash escape sequences, if
present, are decoded as follows:
</p>
<dl compact="compact">
<dt><code>\a</code></dt>
<dd><p>alert (bell)
</p></dd>
<dt><code>\b</code></dt>
<dd><p>backspace
</p></dd>
<dt><code>\e</code></dt>
<dt><code>\E</code></dt>
<dd><p>an escape character (not ANSI C)
</p></dd>
<dt><code>\f</code></dt>
<dd><p>form feed
</p></dd>
<dt><code>\n</code></dt>
<dd><p>newline
</p></dd>
<dt><code>\r</code></dt>
<dd><p>carriage return
</p></dd>
<dt><code>\t</code></dt>
<dd><p>horizontal tab
</p></dd>
<dt><code>\v</code></dt>
<dd><p>vertical tab
</p></dd>
<dt><code>\\</code></dt>
<dd><p>backslash
</p></dd>
<dt><code>\'</code></dt>
<dd><p>single quote
</p></dd>
<dt><code>\"</code></dt>
<dd><p>double quote
</p></dd>
<dt><code>\?</code></dt>
<dd><p>question mark
</p></dd>
<dt><code>\<var>nnn</var></code></dt>
<dd><p>the eight-bit character whose value is the octal value <var>nnn</var>
(one to three digits)
</p></dd>
<dt><code>\x<var>HH</var></code></dt>
<dd><p>the eight-bit character whose value is the hexadecimal value <var>HH</var>
(one or two hex digits)
</p></dd>
<dt><code>\u<var>HHHH</var></code></dt>
<dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
<var>HHHH</var> (one to four hex digits)
</p></dd>
<dt><code>\U<var>HHHHHHHH</var></code></dt>
<dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value
<var>HHHHHHHH</var> (one to eight hex digits)
</p></dd>
<dt><code>\c<var>x</var></code></dt>
<dd><p>a control-<var>x</var> character
</p></dd>
</dl>
<p>The expanded result is single-quoted, as if the dollar sign had not
been present.
</p>
<hr>
<a name="Locale-Translation"></a>
<div class="header">
<p>
Previous: <a href="#ANSI_002dC-Quoting" accesskey="p" rel="prev">ANSI-C Quoting</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Locale_002dSpecific-Translation"></a>
<h4 class="subsubsection">3.1.2.5 Locale-Specific Translation</h4>
<a name="index-localization"></a>
<a name="index-internationalization"></a>
<a name="index-native-languages"></a>
<a name="index-translation_002c-native-languages"></a>
<p>A double-quoted string preceded by a dollar sign (‘<samp>$</samp>’) will cause
the string to be translated according to the current locale.
If the current locale is <code>C</code> or <code>POSIX</code>, the dollar sign
is ignored.
If the string is translated and replaced, the replacement is
double-quoted.
</p>
<a name="index-LC_005fMESSAGES"></a>
<a name="index-TEXTDOMAIN"></a>
<a name="index-TEXTDOMAINDIR"></a>
<p>Some systems use the message catalog selected by the <code>LC_MESSAGES</code>
shell variable. Others create the name of the message catalog from the
value of the <code>TEXTDOMAIN</code> shell variable, possibly adding a
suffix of ‘<samp>.mo</samp>’. If you use the <code>TEXTDOMAIN</code> variable, you
may need to set the <code>TEXTDOMAINDIR</code> variable to the location of
the message catalog files. Still others use both variables in this
fashion:
<code>TEXTDOMAINDIR</code>/<code>LC_MESSAGES</code>/LC_MESSAGES/<code>TEXTDOMAIN</code>.mo.
</p>
<hr>
<a name="Comments"></a>
<div class="header">
<p>
Previous: <a href="#Quoting" accesskey="p" rel="prev">Quoting</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Comments-1"></a>
<h4 class="subsection">3.1.3 Comments</h4>
<a name="index-comments_002c-shell"></a>
<p>In a non-interactive shell, or an interactive shell in which the
<code>interactive_comments</code> option to the <code>shopt</code>
builtin is enabled (see <a href="#The-Shopt-Builtin">The Shopt Builtin</a>),
a word beginning with ‘<samp>#</samp>’
causes that word and all remaining characters on that line to
be ignored. An interactive shell without the <code>interactive_comments</code>
option enabled does not allow comments. The <code>interactive_comments</code>
option is on by default in interactive shells.
See <a href="#Interactive-Shells">Interactive Shells</a>, for a description of what makes
a shell interactive.
</p>
<hr>
<a name="Shell-Commands"></a>
<div class="header">
<p>
Next: <a href="#Shell-Functions" accesskey="n" rel="next">Shell Functions</a>, Previous: <a href="#Shell-Syntax" accesskey="p" rel="prev">Shell Syntax</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Shell-Commands-1"></a>
<h3 class="section">3.2 Shell Commands</h3>
<a name="index-commands_002c-shell"></a>
<p>A simple shell command such as <code>echo a b c</code> consists of the command
itself followed by arguments, separated by spaces.
</p>
<p>More complex shell commands are composed of simple commands arranged together
in a variety of ways: in a pipeline in which the output of one command
becomes the input of a second, in a loop or conditional construct, or in
some other grouping.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">• <a href="#Simple-Commands" accesskey="1">Simple Commands</a>:</td><td> </td><td align="left" valign="top">The most common type of command.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Pipelines" accesskey="2">Pipelines</a>:</td><td> </td><td align="left" valign="top">Connecting the input and output of several
commands.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Lists" accesskey="3">Lists</a>:</td><td> </td><td align="left" valign="top">How to execute commands sequentially.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Compound-Commands" accesskey="4">Compound Commands</a>:</td><td> </td><td align="left" valign="top">Shell commands for control flow.
</td></tr>
<tr><td align="left" valign="top">• <a href="#Coprocesses" accesskey="5">Coprocesses</a>:</td><td> </td><td align="left" valign="top">Two-way communication between commands.
</td></tr>
<tr><td align="left" valign="top">• <a href="#GNU-Parallel" accesskey="6">GNU Parallel</a>:</td><td> </td><td align="left" valign="top">Running commands in parallel.
</td></tr>
</table>
<hr>
<a name="Simple-Commands"></a>
<div class="header">
<p>
Next: <a href="#Pipelines" accesskey="n" rel="next">Pipelines</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Simple-Commands-1"></a>
<h4 class="subsection">3.2.1 Simple Commands</h4>
<a name="index-commands_002c-simple"></a>
<p>A simple command is the kind of command encountered most often.
It’s just a sequence of words separated by <code>blank</code>s, terminated
by one of the shell’s control operators (see <a href="#Definitions">Definitions</a>). The
first word generally specifies a command to be executed, with the
rest of the words being that command’s arguments.
</p>
<p>The return status (see <a href="#Exit-Status">Exit Status</a>) of a simple command is
its exit status as provided
by the <small>POSIX</small> 1003.1 <code>waitpid</code> function, or 128+<var>n</var> if
the command was terminated by signal <var>n</var>.
</p>
<hr>
<a name="Pipelines"></a>
<div class="header">
<p>
Next: <a href="#Lists" accesskey="n" rel="next">Lists</a>, Previous: <a href="#Simple-Commands" accesskey="p" rel="prev">Simple Commands</a>, Up: <a href="#Shell-Commands" accesskey="u" rel="up">Shell Commands</a> [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p>
</div>