summaryrefslogtreecommitdiff
path: root/doc/sh-utils.texi
blob: 36f4efb2def16970f50a864ef4a2e35a13ddf9b6 (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
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
\input texinfo
@c %**start of header
@setfilename sh-utils.info
@settitle GNU shell utilities
@c %**end of header

@include version.texi

@c Define new indices for file names and options.
@defcodeindex fl
@defcodeindex op

@c Put everything in one index (arbitrarily chosen to be the concept index).
@syncodeindex fl cp
@syncodeindex fn cp
@syncodeindex ky cp
@syncodeindex op cp
@syncodeindex pg cp
@syncodeindex vr cp

@ifinfo
@set Francois Franc,ois
@end ifinfo
@tex
@set Francois Fran\noexpand\ptexc cois
@end tex

@ifinfo
@format
START-INFO-DIR-ENTRY
* Shell utilities: (sh-utils).		GNU shell utilities.
* basename: (sh-utils)basename invocation.	Strip directory and suffix.
* date: (sh-utils)date invocation.		Print/set system date and time.
* dirname: (sh-utils)dirname invocation.	Strip non-directory suffix.
* echo: (sh-utils)echo invocation.		Print a line of text.
* env: (sh-utils)env invocation.		Modify the environment.
* expr: (sh-utils)expr invocation.		Evaluate expressions.
* false: (sh-utils)false invocation.		Do nothing, unsuccessfully.
* groups: (sh-utils)groups invocation.		Print group names a user is in.
* hostname: (sh-utils)hostname invocation.	Print or set system name.
* id: (sh-utils)id invocation.			Print real/effective uid/gid.
* logname: (sh-utils)logname invocation.	Print current login name.
* nice: (sh-utils)nice invocation.		Modify scheduling priority.
* nohup: (sh-utils)nohup invocation.		Immunize to hangups.
* pathchk: (sh-utils)pathchk invocation.	Check file name portability.
* printenv: (sh-utils)printenv invocation.	Print environment variables.
* printf: (sh-utils)printf invocation.	        Format and print data.
* pwd: (sh-utils)pwd invocation.	        Print working directory.
* sleep: (sh-utils)sleep invocation.	        Delay for a specified time.
* stty: (sh-utils)stty invocation.	        Print/change terminal settings.
* su: (sh-utils)su invocation.	                Modify user and group id.
* tee: (sh-utils)tee invocation.	        Redirect to multiple files.
* test: (sh-utils)test invocation.	        File/string tests.
* true: (sh-utils)true invocation.	        Do nothing, successfully.
* tty: (sh-utils)tty invocation.	        Print terminal name.
* uname: (sh-utils)uname invocation.	        Print system information.
* users: (sh-utils)users invocation.	        Print current user names.
* who: (sh-utils)who invocation.	        Print who is logged in.
* whoami: (sh-utils)whoami invocation.		Print effective user id.
* yes: (sh-utils)yes invocation.		Print a string indefinitely.
END-INFO-DIR-ENTRY
@end format
@end ifinfo

@ifinfo
This file documents the GNU shell utilities.

Copyright (C) 1994 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).

@end ignore
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@end ifinfo

@titlepage
@title GNU @code{sh-utils}
@subtitle A set of shell utilities
@subtitle for version @value{VERSION}, @value{RELEASEDATE}
@author David MacKenzie et al.

@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1994 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the Foundation.
@end titlepage


@ifinfo
@node Top
@top GNU shell utilities

@cindex shell utilities
@cindex utilities for shell programming

This manual minimally documents version @value{VERSION} of the GNU shell
utilities.

@menu
* Introduction::		Caveats, overview, and authors.
* Common options::              Common options.
* Date input formats::		Specifying date strings.
* Printing text::               echo printf yes
* Conditions::                  false true test expr
* Redirection::                 tee
* File name manipulation::      dirname basename pathchk
* Working context::		pwd stty printenv tty
* User information::            id logname whoami groups users who
* System context::              date uname hostname
* Modified command invocation:: env nice nohup su
* Delaying::                    sleep
* Index::                       General index.
@end menu
@end ifinfo


@node Introduction
@chapter Introduction

@cindex introduction

First of all, this manual is incomplete.  The @code{stty} section, in
particular, needs substantial reorganization and additional explanatory
text before it will be up to the standard of other GNU manuals.
Explanatory text in general is lacking; the manual presently assumes you
pretty much know what to do, and just need to be reminded of how.  Thus,
if you are interested, please get involved in improving this manual.
The entire GNU community will benefit.

Some of these programs are useful only when writing shell scripts;
utilities like these are, in fact, the ``language'' of shell scripts (to
a great extent).  Others are occasionally useful interactively.

@cindex POSIX.2
The GNU shell utilities are mostly compatible with the POSIX.2 standard.

@c This paragraph appears in all of fileutils.texi, textutils.texi, and
@c sh-utils.texi too -- so be sure to keep them consistent.
@cindex bugs, reporting
Please report bugs to @samp{bug-gnu-utils@@prep.ai.mit.edu}.  Remember
to include the version number, machine architecture, input files, and
any other information needed to reproduce the bug: your input, what you
expected, what you got, and why it is wrong.  Diffs are welcome, but
please include a description of the problem as well, since this is
sometimes difficult to infer. @xref{Bugs, , , gcc, GNU CC}.

@cindex history
@cindex MacKenzie, David
@cindex Meyering, Jim
@c Sorry, but the @value trick doesn't work with TeX in indexing
@c commands, and I don't want to fix it right now. --karl.
@cindex Pinard, Francois
@cindex Berry, Karl
@cindex Stallman, Richard
This manual is based on the Unix man pages in the distribution, which
were originally written by David MacKenzie and updated by Jim Meyering.
@value{Francois} Pinard did the initial conversion to Texinfo format.
Karl Berry did the indexing, some reorganization, and editing of the results.
Richard Stallman contributed his usual invaluable insights to the
overall process.


@node Common options
@chapter Common options

@cindex common options

Certain options are available in all these programs.  Rather than
writing identical descriptions for each of the programs, they are
described here.  (In fact, every GNU program accepts (or should accept)
these options.)

Many of these programs take arbitrary strings as arguments.  In those
cases, @samp{--help} and @samp{--version} are taken as these options
only if there is one and exactly one command line argument.

@table @samp

@item --help
@opindex --help
@cindex help, online
Print a usage message listing all available options, then exit successfully.

@item --version
@opindex --version
@cindex version number, finding
Print the version number, then exit successfully.

@end table


@include getdate.texi


@node Printing text
@chapter Printing text

@cindex printing text, commands for
@cindex commands for printing text

This section describes commands that display text strings.

@menu
* echo invocation::             Print a line of text.
* printf invocation::           Format and print data.
* yes invocation::              Print a string until interrupted.
@end menu


@node echo invocation
@section @code{echo}: Print a line of text

@pindex echo
@cindex displaying text
@cindex printing text
@cindex text, displaying
@cindex arbitrary text, displaying

Synopsis:

@example
echo [@var{option}]@dots{} [@var{string}]@dots{}
@end example

@code{echo} writes each given @var{string} to standard output, with a
space between each and a newline after the last one.

The program accepts the following options.  Also see @ref{Common options}.

@table @samp
@item -n
@opindex -n
Do not output the trailing newline.

@item -e
@opindex -e
@cindex backslash escapes
Enable interpretation of the following backslash-escaped characters in
each @var{string}:

@table @samp
@item \a
alert (bell)
@item \b
backspace
@item \c
suppress trailing newline
@item \f
form feed
@item \n
new line
@item \r
carriage return
@item \t
horizontal tab
@item \v
vertical tab
@item \\
backslash
@item \@var{nnn}
the character whose ASCII code is @var{nnn} (octal); if @var{nnn} is not
a valid octal number, it is printed literally.
@end table

@end table


@node printf invocation
@section @code{printf}: Format and print data

@pindex printf
Synopsis:

@example
printf @var{format} [@var{argument}]@dots{}
@end example

@code{printf} prints the @var{format} string, interpreting @samp{%}
directives and @samp{\} escapes in the same way as the C @code{printf}
function.  The @var{format} argument is re-used as necessary to convert
all of the given @var{argument}s.

@code{printf} has one additional directive, @samp{%b}, which prints its
argument string with @samp{\} escapes interpreted in the same way as in
the @var{format} string.

@kindex \0ooo
@kindex \0xhhh
@code{printf} interprets @samp{\0ooo} in @var{format} as an octal number
(if @var{ooo} is 0 to 3 octal digits) specifying a character to print,
and @samp{\xhhh} as a hexadecimal number (if @var{hhh} is 1 to 3 hex
digits) specifying a character to print.

@kindex \c
An additional escape, @samp{\c}, causes @code{printf} to produce no
further output.

The only options are a lone @samp{--help} or
@samp{--version}.  @xref{Common options}.


@node yes invocation
@section @code{yes}: Print a string until interrupted

@pindex yes
@cindex repeated output of a string

@code{yes} prints the command line arguments, separated by spaces and
followed by a newline, forever until it is killed.  If no arguments are
given, it prints @samp{y} followed by a newline forever until killed.

The only options are a lone @samp{--help} or @samp{--version}.
@xref{Common options}.


@node Conditions
@chapter Conditions

@cindex conditions
@cindex commands for exit status
@cindex exit status commands

This section describes commands that are primarily useful for their exit
status, rather than their output.  Thus, they are often used as the
condition of shell @code{if} statements, or as the last command in a
pipeline.

@menu
* false invocation::            Do nothing, unsuccessfully.
* true invocation::             Do nothing, successfully.
* test invocation::             Check file types and compare values.
* expr invocation::             Evaluate expressions.
@end menu


@node false invocation
@section @code{false}: Do nothing, unsuccessfully

@pindex false

@cindex exit status of @code{true}
@cindex failure exit status
@code{false} does nothing except return an exit status of 1, meaning
@dfn{failure}.  It can be used as a place holder in shell scripts
where an unsuccessful command is needed.

Any arguments are ignored, except for a lone @samp{--help} or
@samp{--version} (@pxref{Common options}).


@node true invocation
@section @code{true}: Do nothing, successfully

@pindex true
@cindex do nothing, successfully
@cindex no-op
@cindex successful exit

@cindex exit status of @code{true}
@code{true} does nothing except return an exit status of 0, meaning
@dfn{success}.  It can be used as a place holder in shell scripts
where a successful command is needed, although the shell built-in
command @code{:} (colon) may be faster.

Any arguments are ignored, except for a lone @samp{--help} or
@samp{--version} (@pxref{Common options}).


@node test invocation
@section @code{test}: Check file types and compare values

@pindex test
@cindex check file types
@cindex compare values
@cindex expression evaluation

@code{test} returns a status of 0 (true) or 1 (false) depending on the
evaluation of the conditional expression @var{expr}.  Each part of the
expression must be a separate argument.

@code{test} has file status checks, string operators, and numeric
comparison operators.

@cindex conflicts with shell built-ins
@cindex built-in shell commands, conflicts with
Because most shells have a built-in command by the same name, using the
unadorned command name in a script or interactively may get you
different functionality than that described here.

Besides the options below, @code{test} accepts a lone @samp{--help} or
@samp{--version}.  @xref{Common options}.  A single non-option argument
is also allowed: @code{test} returns true if the argument is not null.

@menu
* File type tests::             -[bcdfhLpSt]
* Access permission tests::     -[gkruwxOG]
* File characteristics tests::  -e -s -nt -ot -ef
* String tests::                -z -n = !=
* Numeric tests::               -eq -ne -lt -le -gt -ge
* Connectives for test::        ! -a -o
@end menu


@node File type tests
@subsection File type tests

@cindex file type tests

These options test for particular types of files.  (Everything's a file,
but not all files are the same!)

@table @samp

@item -b @var{file}
@opindex -b
@cindex block special check
True if @var{file} exists and is a block special device.

@item -c @var{file}
@opindex -c
@cindex character special check
True if @var{file} exists and is a character special device.

@item -d @var{file}
@opindex -d
@cindex directory check
True if @var{file} exists and is a directory.

@item -f @var{file}
@opindex -f
@cindex regular file check
True if @var{file} exists and is a regular file.

@item -h @var{file}
@itemx -L @var{file}
@opindex -L
@opindex -h
@cindex symbolic link check
True if @var{file} exists and is a symbolic link.

@item -p @var{file}
@opindex -p
@cindex named pipe check
True if @var{file} exists and is a named pipe.

@item -S @var{file}
@opindex -S
@cindex socket check
True if @var{file} exists and is a socket.

@item -t [@var{fd}]
@opindex -t
@cindex terminal check
True if @var{fd} is opened on a terminal.  If @var{fd} is omitted, it
defaults to 1 (standard output).

@end table


@node Access permission tests
@subsection Access permission tests

@cindex access permission tests
@cindex permission tests

These options test for particular access permissions.

@table @samp

@item -g @var{file}
@opindex -g
@cindex set-group-id check
True if @var{file} exists and has its set-group-id bit set.

@item -k @var{file}
@opindex -k
@cindex sticky bit check
True if @var{file} has its @dfn{sticky} bit set.

@item -r @var{file}
@opindex -r
@cindex readable file check
True if @var{file} exists and is readable.

@item -u @var{file}
@opindex -u
@cindex set-user-id check
True if @var{file} exists and has its set-user-id bit set.

@item -w @var{file}
@opindex -w
@cindex writable file check
True if @var{file} exists and is writable.

@item -x @var{file}
@opindex -x
@cindex executable file check
True if @var{file} exists and is executable.

@item -O @var{file}
@opindex -O
@cindex owned by effective uid check
True if @var{file} exists and is owned by the current effective user id.

@item -G @var{file}
@opindex -G
@cindex owned by effective gid check
True if @var{file} exists and is owned by the current effective group id.

@end table

@node File characteristics tests
@subsection File characteristics tests

@cindex file characteristics tests

These options test other file characteristics.

@table @samp

@item -e @var{file}
@opindex -e
@cindex existence-of-file check
True if @var{file} exists.

@item -s @var{file}
@opindex -s
@cindex nonempty file check
True if @var{file} exists and has a size greater than zero.

@item @var{file1} -nt @var{file2}
@opindex -nt
@cindex newer-than file check
True if @var{file1} is newer (according to modification date) than
@var{file2}.

@item @var{file1} -ot @var{file2}
@opindex -ot
@cindex older-than file check
True if @var{file1} is older (according to modification date) than
@var{file2}.

@item @var{file1} -ef @var{file2}
@opindex -ef
@cindex same file check
@cindex hard link check
True if @var{file1} and @var{file2} have the same device and inode
numbers, i.e., if they are hard links to each other.

@end table


@node String tests
@subsection String tests

@cindex string tests

These options test string characteristics.  Strings are not quoted for
@code{test}, though you may need to quote them to protect characters
with special meaning to the shell, e.g., spaces.

@table @samp

@item -z @var{string}
@opindex -z
@cindex zero-length string check
True if the length of @var{string} is zero.

@item -n @var{string}
@itemx @var{string}
@opindex -n
@cindex nonzero-length string check
True if the length of @var{string} is non-zero.

@item @var{string1} = @var{string2}
@opindex =
@cindex equal string check
True if the strings are equal.

@item @var{string1} != @var{string2}
@opindex !=
@cindex not-equal string check
True if the strings are not equal.

@end table


@node Numeric tests
@subsection Numeric tests

@cindex numeric tests
@cindex arithmetic tests

Numeric relationals.  The arguments must be entirely numeric (possibly
negative), or the special expression @w{@code{-l @var{string}}}, which
evaluates to the length of @var{string}.

@table @samp

@item @var{arg1} -eq @var{arg2}
@itemx @var{arg1} -ne @var{arg2}
@itemx @var{arg1} -lt @var{arg2}
@itemx @var{arg1} -le @var{arg2}
@itemx @var{arg1} -gt @var{arg2}
@itemx @var{arg1} -ge @var{arg2}
@opindex -eq
@opindex -ne
@opindex -lt
@opindex -le
@opindex -gt
@opindex -ge
These arithmetic binary operators return true if @var{arg1} is equal,
not-equal, less-than, less-than-or-equal, greater-than, or
greater-than-or-equal than @var{arg2}, respectively.

@end table

For example:

@example
test -1 -gt -2 && echo yes
@result{} yes
test -l abc -gt 1 && echo yes
@result{} yes
test 0x100 -eq 1
@error{} test: integer expression expected before -eq
@end example


@node Connectives for test
@subsection Connectives for @code{test}

@cindex logical connectives
@cindex connectives, logical

The usual logical connectives.

@table @samp

@item ! @var{expr}
@opindex !
True if @var{expr} is false.

@item @var{expr1} -a @var{expr2}
@opindex -a
@cindex logical and operator
@cindex and operator
True if both @var{expr1} and @var{expr2} are true.

@item @var{expr1} -o @var{expr2}
@opindex -o
@cindex logical or operator
@cindex or operator
True if either @var{expr1} or @var{expr2} is true.

@end table


@node expr invocation
@section @code{expr}: Evaluate expressions

@pindex expr
@cindex expression evaluation
@cindex evaluation of expressions

@code{expr} evaluates an expression and writes the result on standard
output.  Each token of the expression must be a separate argument.

Operands are either numbers or strings.  @code{expr} coerces
anything appearing in an operand position to an integer or a string
depending on the operation being applied to it.

Strings are not quoted for @code{expr}, though you may need to quote
them to protect characters with special meaning to the shell, e.g.,
spaces.

@cindex parentheses for grouping
Operators may given as infix symbols or prefix keywords.  Parentheses
may be used for grouping in the usual manner (you must quote parentheses
to avoid the shell evaluating them, however).

@cindex exit status of @code{expr}
Exit status:

@display
0 if the expression is neither null nor 0,
1 if the expression is null or 0,
2 for invalid expressions.
@end display

@menu
* Relations for expr::          | & < <= = == != >= >
* Numeric expressions::         + - * / %
* String expressions::          : match substr index length
* Examples of expr::            Examples.
@end menu


@node Relations for expr
@subsection Relations for @code{expr}

@cindex connectives, logical
@cindex logical connectives
@cindex relations, numeric or string

The usual logical connectives and relations, in order of precedence.

@table @samp

@item |
@kindex |
@cindex logical or operator
@cindex or operator
Yields its first argument if it is neither null nor 0, otherwise its
second argument.

@item &
@kindex &
@cindex logical and operator
@cindex and operator
Yields its first argument if neither argument is null or 0, otherwise
0.

@item < <= = == != >= >
@kindex <
@kindex <=
@kindex =
@kindex ==
@kindex >
@kindex >=
@cindex comparison operators
Compare the arguments and return 1 if the relation is true, 0 otherwise.
@code{==} is a synonym for @code{=}.  @code{expr} first tries to coerce
both arguments to numbers and do a numeric comparison; if either
coercion fails, it does a lexicographic comparison.

@end table


@node Numeric expressions
@subsection Numeric expressions

@cindex numeric expressions
@cindex expressions, numeric

Numeric operators, in order of increasing precedence.  The connectives
(previous section) have higher precedence, the string operators
(following section) have lower.

@table @samp

@item + -
@kindex +
@kindex -
@cindex addition
@cindex subtraction
Addition and subtraction.  Both arguments are coerced to numbers;
an error occurs if this cannot be done.

@item * / %
@kindex *
@kindex /
@kindex %
@cindex multiplication
@cindex division
@cindex remainder
Multiplication, division, remainder.  Both arguments are coerced to
numbers; an error occurs if this cannot be done.

@end table


@node String expressions
@subsection String expressions

@cindex string expressions
@cindex expressions, string

String operators.  These have lowest precedence.

@table @samp

@item @var{string} : @var{regex}
@cindex pattern matching
@cindex regular expression matching
@cindex matching patterns
Perform pattern matching.  The arguments are coerced to strings and the
second is considered to be a (basic, a la @code{grep}) regular
expression, with a @code{^} implicitly prepended.  The first argument is
then matched against this regular expression.

If the match succeeds and @var{regex} uses @samp{\(} and @samp{\)}, the
@code{:} expression returns the part of @var{string} that matched the
subexpression; otherwise, it returns the number of characters matched.

If the match fails, the @code{:} operator returns the null string if
@samp{\(} and @samp{\)} are used in @var{regex}, otherwise 0.

Only the first @samp{\( @dots{} \)} pair is relevant to the return
value; additional pairs are meaningful only for grouping the regular
expression operators.

@xref{Top, , Regular Expression Library, regex, Regex}, for details of
regular expression syntax.

@item match @var{string} @var{regex}
@findex match
An alternative way to do pattern matching.  This is the same as
@w{@samp{@var{string} : @var{regex}}}.

@item substr @var{string} @var{position} @var{length}
@findex substr
Returns the substring of @var{string} beginning at @var{position}
with length at most @var{length}.  If either @var{position} or
@var{length} is negative or non-numeric, returns the null string.

@item index @var{string} @var{character-class}
@findex index
Returns the first position in @var{string} where the first character in
@var{charset} was found.  If no character in @var{charset} is found in
@var{string}, return 0.

@item length @var{string}
@findex length
Returns the length of @var{string}.

@end table

The keywords cannot be used as strings.


@node Examples of expr
@subsection Examples of @code{expr}

@cindex examples of @code{expr}
Here are a few examples, including quoting for shell metacharacters.

To add 1 to the shell variable @code{foo}, in Bourne-compatible shells:
@example
foo=`expr $foo + 1`
@end example

To print the non-directory part of the file name stored in
@code{$fname}, which need not contain a @code{/}.
@example
expr $fname : '.*/\(^.*\)' '^|' $fname
@end example

@example
expr abc : 'a\(.\)c'
@result{} b
expr index abcdef cz
@result{} 3
expr index index a
@error{} expr: syntax error

@end example


@node Redirection
@chapter Redirection

@cindex redirection
@cindex commands for redirection

Unix shells commonly provide several forms of @dfn{redirection}---ways
to change the input source or output destination of a command.  But one
useful redirection is performed by a separate command, not by the shell;
it's described here.


@menu
* tee invocation::              Redirect output to multiple files.
@end menu

@node tee invocation
@section @code{tee}: Redirect output to multiple files

@pindex tee
@cindex pipe fitting
@cindex destinations, multiple output
@cindex read from stdin and write to stdout and files

The @code{tee} command copies standard input to standard output and also
to any files given as arguments.  This is useful when you want not only
to send some data down a pipe, but also to save a copy.

Synopsis:

@example
tee [@var{option}]@dots{} [@var{file}]@dots{}
@end example

If a file being written to does not already exist, it is created.  If a
file being written to already exists, the data it previously contained
is overwritten unless the @code{-a} option is used.

The program accepts the following options.  Also see @ref{Common options}.

@table @samp
@item -a
@itemx --append
@opindex -a
@opindex --append
Append standard input to the given files rather than overwriting
them.

@item -i
@itemx --ignore-interrupts
@opindex -i
@opindex --ignore-interrupts
Ignore interrupt signals.

@end table


@node File name manipulation
@chapter File name manipulation

@cindex file name manipulation
@cindex manipulation of file names
@cindex commands for file name manipulation

This section describes commands that manipulate file names.

@menu
* basename invocation::         Strip directory and suffix from a file name.
* dirname invocation::          Strip non-directory suffix from a file name.
* pathchk invocation::          Check file name portability.
@end menu


@node basename invocation
@section @code{basename}: Strip directory and suffix from a file name

@pindex basename
@cindex strip directory and suffix from file names
@cindex directory, stripping from file names
@cindex suffix, stripping from file names
@cindex file names, stripping directory and suffix
@cindex leading directory components, stripping

Synopsis:

@example
basename @var{name} [@var{suffix}]
@end example

The @code{basename} command removes any leading directory components
from @var{name}.  If @var{suffix} is specified and is identical
to the end of @var{name}, it is removed from @var{name} as well.
@code{basename} prints the result on standard output.

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node dirname invocation
@section @code{dirname}: Strip non-directory suffix from a file name

@pindex dirname
@cindex directory components, printing
@cindex stripping non-directory suffix
@cindex non-directory suffix, stripping

Synopsis:

@example
dirname @var{name}
@end example

@code{dirname} prints all but the final slash-delimited component
of @var{name}.  If @var{name} is a single component,
@code{dirname} prints @samp{.} (meaning the current directory).

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node pathchk invocation
@section @code{pathchk}: Check file name portability

@pindex pathchk
@cindex file names, checking validity and portability
@cindex valid file names, checking for
@cindex portable file names, checking for

Synopsis:

@example
pathchk [@var{option}]@dots{} @var{name}@dots{}
@end example

For each @var{name}, @code{pathchk} prints a message if any of
these conditions is true:
@enumerate
@item
one of the existing directories in @var{name} does not have search
(execute) permission,
@item
the length of @var{name} is larger than its filesystem's maximum
file name length,
@item
the length of one component of @var{name}, corresponding to an
existing directory name, is larger than its filesystem's maximum
length for a file name component.
@end enumerate

The program accepts the following option.  Also see @ref{Common options}.

@table @samp

@item -p
@itemx --portability
@opindex -p
@opindex --portability
Instead of performing length checks on the underlying filesystem,
test the length of each file name and its components against the
POSIX.1 minimum limits for portability.  Also check that the file
name contains no characters not in the portable file name character set.

@end table

@cindex exit status of @code{pathchk}
Exit status:

@display
0 if all specified file names passed all of the tests,
1 otherwise.
@end display


@node Working context
@chapter Working context

@cindex working context
@cindex commands for printing the working context

This section describes commands that display or alter the context in
which you are working: the current directory, the terminal settings, and
so forth.  See also the user-related commands in the next section.

@menu
* pwd invocation::              Print working directory.
* stty invocation::             Print or change terminal characteristics.
* printenv invocation::         Print environment variables.
* tty invocation::              Print file name of terminal on standard input.
@end menu


@node pwd invocation
@section @code{pwd}: Print working directory

@pindex pwd
@cindex print name of current directory
@cindex current working directory, printing
@cindex working directory, printing

@cindex symbolic links and @code{pwd}
@code{pwd} prints the fully resolved name of the current directory.
That is, all components of the printed name will be actual directory
names---none will be symbolic links.

@cindex conflicts with shell built-ins
@cindex built-in shell commands, conflicts with
Because most shells have a built-in command by the same name, using the
unadorned command name in a script or interactively may get you
different functionality than that described here.

The only options are a lone @samp{--help} or
@samp{--version}.  @xref{Common options}.


@node stty invocation
@section @code{stty}: Print or change terminal characteristics

@pindex stty
@cindex change or print terminal settings
@cindex terminal settings
@cindex line settings of terminal

If given no arguments, @code{stty} prints the baud rate, line
discipline number (on systems that support it), and line settings
that have been changed from the values set by @samp{stty sane}.
Mode reading and setting are performed on the tty line connected to
standard input.

@code{stty} accepts many non-option arguments that change aspects of
the terminal line operation, as described below.

Synopses:

@example
stty [@var{setting}]@dots{}
stty [@var{option}]
@end example

The program accepts the following options.  Also see @ref{Common options}.

@table @samp
@item -a
@itemx --all
@opindex -a
@opindex --all
Print all current settings in human-readable form.

@item -g
@itemx --save
@opindex -g
@opindex --save
@cindex machine-readable @code{stty} output
Print all current settings in a form that can be used as an argument to
another @code{stty} command to restore the current settings.

@end table

Many settings can be turned off by preceding them with a @samp{-}.
Such arguments are marked below with ``May be negated'' in their
description.  The descriptions themselves refer to the positive
case, that is, when @emph{not} negated (unless stated otherwise,
of course).

Some settings are not available on all POSIX systems, since they use
extensions.  Such arguments are marked below with ``Non-POSIX'' in their
description.  On non-POSIX systems, those or other settings also may not
be available, but it's not feasible to document all the variations: just
try it and see.

@menu
* Control::                     Control settings
* Input::                       Input settings
* Output::                      Output settings
* Local::                       Local settings
* Combination::                 Combination settings
* Characters::                  Special characters
* Special::                     Special settings
@end menu


@node Control
@subsection Control settings

@cindex control settings
Control settings:

@table @samp
@item parenb
@opindex parenb
@cindex two-way parity
Generate parity bit in output and expect parity bit in input.
May be negated.

@item parodd
@opindex parodd
@cindex odd parity
@cindex even parity
Set odd parity (even if negated).  May be negated.

@item cs5
@itemx cs6
@itemx cs7
@itemx cs8
@opindex cs@var{n}
@cindex character size
@cindex eight-bit characters
Set character size to 5, 6, 7, or 8 bits.

@item hup
@itemx hupcl
@opindex hup[cl]
Send a hangup signal when the last process closes the tty.  May be
negated.

@item cstopb
@opindex cstopb
@cindex stop bits
Use two stop bits per character (one if negated).  May be negated.

@item cread
@opindex cread
Allow input to be received.  May be negated.

@item clocal
@opindex clocal
@cindex modem control
Disable modem control signals.  May be negated.

@item crtscts
@opindex crtscts
@cindex hardware flow control
@cindex flow control, hardware
@cindex RTS/CTS flow control
Enable RTS/CTS flow control.  Non-POSIX.  May be negated.
@end table


@node Input
@subsection Input settings

@cindex input settings

@table @samp
@item ignbrk
@opindex ignbrk
@cindex breaks, ignoring
Ignore break characters.  May be negated.

@item brkint
@opindex brkint
@cindex breaks, cause interrupts
Make breaks cause an interrupt signal.  May be negated.

@item ignpar
@opindex ignpar
@cindex parity, ignoring
Ignore characters with parity errors.  May be negated.

@item parmrk
@opindex parmrk
@cindex parity errors, marking
Mark parity errors (with a 255-0-character sequence).  May be negated.

@item inpck
@opindex inpck
Enable input parity checking.  May be negated.

@item istrip
@opindex istrip
@cindex eight-bit input
Clear high (8th) bit of input characters.  May be negated.

@item inlcr
@opindex inlcr
@cindex newline, translating to return
Translate newline to carriage return.  May be negated.

@item igncr
@opindex igncr
@cindex return, ignoring
Ignore carriage return.  May be negated.

@item icrnl
@opindex icrnl
@cindex return, translating to newline
Translate carriage return to newline.  May be negated.

@item ixon
@opindex ixon
@kindex C-s/C-q flow control
@cindex XON/XOFF flow control
Enable XON/XOFF flow control (that is, @key{CTRL-s}/@key{CTRL-Q}).  May
be negated.

@item ixoff
@itemx tandem
@opindex ixoff
@opindex tandem
@cindex software flow control
@cindex flow control, software
Enable sending of @code{stop} character when the system input buffer
is almost full, and @code{start} character when it becomes almost
empty again.  May be negated.

@item iuclc
@opindex iuclc
@cindex uppercase, translating to lowercase
Translate uppercase characters to lowercase.  Non-POSIX.  May be
negated.

@item ixany
@opindex ixany
Allow any character to restart output (only the start character
if negated).  Non-POSIX.  May be negated.

@item imaxbel
@opindex imaxbel
@cindex beeping at input buffer full
Enable beeping and not flushing input buffer if a character arrives
when the input buffer is full.  Non-POSIX.  May be negated.
@end table


@node Output
@subsection Output settings

@cindex output settings
These arguments specify output-related operations.

@table @samp
@item opost
@opindex opost
Postprocess output.  May be negated.

@item olcuc
@opindex olcuc
@cindex lowercase, translating to output
Translate lowercase characters to uppercase.  Non-POSIX.  May be
negated.

@item ocrnl
@opindex ocrnl
@cindex return, translating to newline
Translate carriage return to newline.  Non-POSIX.  May be negated.

@item onlcr
@opindex onlcr
@cindex newline, translating to crlf
Translate newline to carriage return-newline.  Non-POSIX.  May be
negated.

@item onocr
@opindex onocr
Do not print carriage returns in the first column.  Non-POSIX.
May be negated.

@item onlret
@opindex onlret
Newline performs a carriage return.  Non-POSIX.  May be negated.

@item ofill
@opindex ofill
@cindex pad instead of timing for delaying
Use fill (padding) characters instead of timing for delays.  Non-POSIX.
May be negated.

@item ofdel
@opindex ofdel
@cindex pad character
Use delete characters for fill instead of null characters.  Non-POSIX.
May be negated.

@item nl1
@itemx nl0
@opindex nl@var{n}
Newline delay style.  Non-POSIX.

@item cr3
@itemx cr2
@itemx cr1
@itemx cr0
@opindex cr@var{n}
Carriage return delay style.  Non-POSIX.

@item tab3
@itemx tab2
@itemx tab1
@itemx tab0
@opindex tab@var{n}
Horizontal tab delay style.  Non-POSIX.

@item bs1
@itemx bs0
@opindex bs@var{n}
Backspace delay style.  Non-POSIX.

@item vt1
@itemx vt0
@opindex vt@var{n}
Vertical tab delay style.  Non-POSIX.

@item ff1
@itemx ff0
@opindex ff@var{n}
Form feed delay style.  Non-POSIX.
@end table


@node Local
@subsection Local settings

@cindex local settings

@table @samp
@item isig
@opindex isig
Enable @code{interrupt}, @code{quit}, and @code{suspend} special
characters.  May be negated.

@item icanon
@opindex icanon
Enable @code{erase}, @code{kill}, @code{werase}, and @code{rprnt}
special characters.  May be negated.

@item iexten
@opindex iexten
Enable non-POSIX special characters.  May be negated.

@item echo
@opindex echo
Echo input characters.  May be negated.

@item echoe
@itemx crterase
@opindex echoe
@opindex crterase
Echo @code{erase} characters as backspace-space-backspace.  May be
negated.

@item echok
@opindex echok
@cindex newline echoing after @code{kill}
Echo a newline after a @code{kill} character.  May be negated.

@item echonl
@opindex echonl
@cindex newline, echoing
Echo newline even if not echoing other characters.  May be negated.

@item noflsh
@opindex noflsh
@cindex flushing, disabling
Disable flushing after @code{interrupt} and @code{quit} special
characters.  May be negated.

@item xcase
@opindex xcase
@cindex case translation
Enable input and output of uppercase characters by preceding their
lowercase equivalents with @samp{\}, when @code{icanon} is set.
Non-POSIX.  May be negated.

@item tostop
@opindex tostop
@cindex background jobs, stopping at terminal write
Stop background jobs that try to write to the terminal.  Non-POSIX.
May be negated.

@item echoprt
@itemx prterase
@opindex echoprt
@opindex prterase
Echo erased characters backward, between @samp{\} and @samp{/}.
Non-POSIX.  May be negated.

@item echoctl
@itemx ctlecho
@opindex echoctl
@opindex ctlecho
@cindex control characters, using @samp{^@var{c}}
@cindex hat notation for control characters
Echo control characters in hat notation (@samp{^@var{c}}) instead
of literally.  Non-POSIX.  May be negated.

@item echoke
@itemx crtkill
@opindex echoke
@opindex crtkill
Echo the @code{kill} special character by erasing each character on
the line as indicated by the @code{echoprt} and @code{echoe} settings,
instead of by the @code{echoctl} and @code{echok} settings.  Non-POSIX.
May be negated.
@end table


@node Combination
@subsection Combination settings

@cindex combination settings
Combination settings:

@table @samp
@item evenp
@opindex evenp
@itemx parity
@opindex parity
Same as @code{parenb -parodd cs7}.  May be negated.  If negated, same
as @code{-parenb cs8}.

@item oddp
@opindex oddp
Same as @code{parenb parodd cs7}.  May be negated.  If negated, same
as @code{-parenb cs8}.

@item nl
@opindex nl
Same as @code{-icrnl -onlcr}.  May be negated.  If negated, same as
@code{icrnl -inlcr -igncr onlcr -ocrnl -onlret}.

@item ek
@opindex ek
Reset the @code{erase} and @code{kill} special characters to their default
values.

@item sane
@opindex sane
Same as:
@c This is too long to write inline.
@example
cread -ignbrk brkint -inlcr -igncr icrnl -ixoff -iuclc -ixany
imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel
nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl
-noflsh -xcase -tostop -echoprt echoctl echoke
@end example
@noindent and also sets all special characters to their default values.

@item cooked
@opindex cooked
Same as @code{brkint ignpar istrip icrnl ixon opost isig icanon}, plus
sets the @code{eof} and @code{eol} characters to their default values
if they are the same as the @code{min} and @code{time} characters.
May be negated.  If negated, same as @code{raw}.

@item raw
@opindex raw
Same as:
@example
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr
-icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -isig -icanon
-xcase min 1 time 0
@end example
@noindent May be negated.  If negated, same as @code{cooked}.

@item cbreak
@opindex cbreak
Same as @code{-icanon}.  May be negated.  If negated, same as
@code{icanon}.

@item pass8
@opindex pass8
@cindex eight-bit characters
Same as @code{-parenb -istrip cs8}.  May be negated.  If negated,
same as @code{parenb istrip cs7}.

@item litout
@opindex litout
Same as @code{-parenb -istrip -opost cs8}.  May be negated.
If negated, same as @code{parenb istrip opost cs7}.

@item decctlq
@opindex decctlq
Same as @code{-ixany}.  Non-POSIX.  May be negated.

@item tabs
@opindex tabs
Same as @code{tab0}.  Non-POSIX.  May be negated.  If negated, same
as @code{tab3}.

@item lcase
@itemx LCASE
@opindex lcase
@opindex LCASE
Same as @code{xcase iuclc olcuc}.  Non-POSIX.  May be negated.

@item crt
@opindex crt
Same as @code{echoe echoctl echoke}.

@item dec
@opindex dec
Same as @code{echoe echoctl echoke -ixany intr ^C erase ^? kill C-u}.
@end table


@node Characters
@subsection Special characters

@cindex special characters
@cindex characters, special

The special characters' default values vary from system to system.
They are set with the syntax @samp{name value}, where the names are
listed below and the value can be given either literally, in hat
notation (@samp{^@var{c}}), or as an integer which may start with
@samp{0x} to indicate hexadecimal, @samp{0} to indicate octal, or
any other digit to indicate decimal.

@cindex disabling special characters
@kindex u@r{, and disabling special characters}
For GNU stty, giving a value of @code{^-} or @code{undef} disables that
special character.  (This is incompatible with Ultrix @code{stty},
which uses  a value of @samp{u} to disable a special character.  GNU
@code{stty} treats a value @samp{u} like any other, namely to set that
special character to @key{u}.)

@table @samp

@item intr
@opindex intr
Send an interrupt signal.

@item quit
@opindex quit
Send a quit signal.

@item erase
@opindex erase
Erase the last character typed.

@item kill
@opindex kill
Erase the current line.

@item eof
@opindex eof
Send an end of file (terminate the input).

@item eol
@opindex eol
End the line.

@item eol2
@opindex eol2
Alternate character to end the line.  Non-POSIX.

@item swtch
@opindex swtch
Switch to a different shell layer.  Non-POSIX.

@item start
@opindex start
Restart the output after stopping it.

@item stop
@opindex stop
Stop the output.

@item susp
@opindex susp
Send a terminal stop signal.

@item dsusp
@opindex dsusp
Send a terminal stop signal after flushing the input.  Non-POSIX.

@item rprnt
@opindex rprnt
Redraw the current line.  Non-POSIX.

@item werase
@opindex werase
Erase the last word typed.  Non-POSIX.

@item lnext
@opindex lnext
Enter the next character typed literally, even if it is a special
character.  Non-POSIX.
@end table


@node Special
@subsection Special settings

@cindex special settings

@table @samp
@item min @var{n}
@opindex min
Set the minimum number of characters that will satisfy a read until
the time value has expired, when @code{-icanon} is set.

@item time @var{n}
@opindex time
Set the number of tenths of a second before reads time out if the min
number of characters have not been read, when @code{-icanon} is set.

@item ispeed @var{n}
@opindex ispeed
Set the input speed to @var{n}.

@item ospeed @var{n}
@opindex ospeed
Set the output speed to @var{n}.

@item rows @var{n}
@opindex rows
Tell the tty kernel driver that the terminal has @var{n} rows.  Non-POSIX.

@item cols @var{n}
@itemx columns @var{n}
@opindex cols
@opindex columns
Tell the kernel that the terminal has @var{n} columns.  Non-POSIX.

@item size
@opindex size
@vindex LINES
@vindex COLUMNS
Print the number of rows and columns that the kernel thinks the
terminal has.  (Systems that don't support rows and cols in the kernel
typically use the environment variables @code{LINES} and @code{COLUMNS}
instead; however, GNU @code{stty} does not know anything about them.)
Non-POSIX.

@item line @var{n}
@opindex line
Use line discipline @var{n}.  Non-POSIX.

@item speed
@opindex speed
Print the terminal speed.

@item @var{n}
@cindex baud rate, setting
Set the input and output speeds to @var{n}.  @var{n} can be one
of: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600
19200 38400 @code{exta} @code{extb}.  @code{exta} is the same as
19200; @code{extb} is the same as 38400.  0 hangs up the line if
@code{-clocal} is set.
@end table


@node printenv invocation
@section @code{printenv}: Print all or some environment variables

@pindex printenv
@cindex printing all or some environment variables
@cindex environment variables, printing

Synopsis:

@example
printenv [@var{option}] [@var{variable}]@dots{}
@end example

If no @var{variable}s are specified, @code{printenv} prints the value of
every environment variable.  Otherwise, it prints the value of each
@var{variable} that is set, and nothing for those that are not set.

The only options are a lone @samp{--help} or @samp{--version}.
@xref{Common options}.

@cindex exit status of @code{printenv}
Exit status:

@display
0 if all variables specified were found
1 if at least one specified variable was not found
2 if a write error occurred
@end display


@node tty invocation
@section @code{tty}: Print file name of terminal on standard input

@pindex tty
@cindex print terminal file name
@cindex terminal file name, printing

@code{tty} prints the file name of the tty connected to its standard
input.  It prints @samp{not a tty} if standard input is not a tty.

Synopsis:

@example
tty [@var{option}]@dots{}
@end example

The program accepts the following option.  Also see @ref{Common options}.

@table @samp

@item -s
@itemx --silent
@itemx --quiet
@opindex -s
@opindex --silent
@opindex --quiet
Print nothing; only return an exit status.

@end table

@cindex exit status of @code{tty}
Exit status:

@display
0 if standard input is a tty
1 if standard input is not a tty
2 if given incorrect arguments
3 if a write error occurs
@end display


@node User information
@chapter User information

@cindex user information, commands for
@cindex commands for printing user information

This section describes commands that print user-related information:
logins, groups, and so forth.

@menu
* id invocation::               Print real and effective uid and gid.
* logname invocation::          Print current login name.
* whoami invocation::           Print effective user id.
* groups invocation::           Print group names a user is in.
* users invocation::            Print login names of users currently logged in.
* who invocation::              Print who is currently logged in.
@end menu


@node id invocation
@section @code{id}: Print real and effective uid and gid

@pindex id
@cindex real uid and gid, printing
@cindex effective uid and gid, printing
@cindex printing real and effective uid and gid

@noindent @code{id} prints information about the given user, or the process
running it if no user is specified.

Synopsis:

@example
id [@var{option}]@dots{} [@var{username}]
@end example

By default, it prints the real user id, real group id, effective user id
if different from the real user id, effective group id if different from
the real group id, and supplemental group ids.

Each of these numeric values is preceded by an identifying string and
followed by the corresponding user or group name in parentheses.

The options cause @code{id} to print only part of the above information.
Also see @ref{Common options}.

@table @samp
@item -g
@itemx --group
@opindex -g
@opindex --group
Print only the group id.

@item -G
@itemx --groups
@opindex -G
@opindex --groups
Print only the supplementary groups.

@item -n
@itemx --name
@opindex -n
@opindex --name
Print the user or group name instead of the ID number.  Requires
@code{-u}, @code{-g}, or @code{-G}.

@item -r
@itemx --real
@opindex -r
@opindex --real
Print the real, instead of effective, user or group id.  Requires
@code{-u}, @code{-g}, or @code{-G}.

@item -u
@itemx --user
@opindex -u
@opindex --user
Print only the user id.

@end table


@node logname invocation
@section @code{logname}: Print current login name

@pindex logname
@cindex printing user's login name
@cindex login name, printing
@cindex user name, printing

@flindex /etc/utmp
@flindex utmp

@code{logname} prints the calling user's name, as found in the file
@file{/etc/utmp}, and exits with a status of 0.  If there is no
@file{/etc/utmp} entry for the calling process, @code{logname} prints
an error message and exits with a status of 1.

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node whoami invocation
@section @code{whoami}: Print effective user id

@pindex whoami
@cindex effective UID, printing
@cindex printing the effective UID

@code{whoami} prints the user name associated with the current
effective user id.  It is equivalent to the command @samp{id -un}.

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node groups invocation
@section @code{groups}: Print group names a user is in

@pindex groups
@cindex printing groups a user is in
@cindex supplementary groups, printing

@code{groups} prints the names of the primary and any supplementary
groups that each given @var{username}, or the current process if none
are given, is in.  If user names are given, the name of each user is
printed before the list of that user's groups.

Synopsis:

@example
groups [@var{username}]@dots{}
@end example

The group lists are equivalent to the output of the command @samp{id -Gn}.

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node users invocation
@section @code{users}: Print login names of users currently logged in

@pindex users
@cindex printing current usernames
@cindex usernames, printing current

@cindex login sessions, printing users with
@code{users} prints on a single line a blank-separated list of user
names of users currently logged in to the current host.  Each user name
corresponds to a login session, so if a user has more than one login
session, that user's name will appear the same number of times in the
output.

Synopsis:

@example
users [@var{file}]
@end example

@flindex /etc/utmp
@flindex /etc/wtmp
With no @var{file} argument, @code{users} extracts its information from
the file @file{/etc/utmp}.  If a file argument is given, @code{users}
uses that file instead.  A common choice is @file{/etc/wtmp}.

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node who invocation
@section @code{who}: Print who is currently logged in

@pindex who
@cindex printing current user information
@cindex information, about current users

Synopsis:

@example
@code{who} [@var{option}] [@var{file}] [am i]
@end example

@cindex terminal lines, currently used
@cindex login time
@cindex remote hostname
If given no non-option arguments, @code{who} prints the following
information for each user currently logged on: login name, terminal
line, login time, and remote hostname or X display.

@flindex /etc/utmp
@flindex /etc/wtmp
If given one non-option argument, @code{who} uses that instead of
@file{/etc/utmp} as the name of the file containing the record of
users logged on.  @file{/etc/wtmp} is commonly given as an argument
to @code{who} to look at who has previously logged on.

@opindex am i
@opindex who am i
If given two non-option arguments, @code{who} prints only the entry
for the user running it (determined from its standard input), preceded
by the hostname.  Traditionally, the two arguments given are @samp{am
i}, as in @samp{who am i}.

The program accepts the following options.  Also see @ref{Common options}.

@table @samp
@item -m
@opindex -m
Same as @samp{who am i}.

@item -q
@itemx --count
@opindex -q
@opindex --count
Print only the login names and the number of users logged on.
Overrides all other options.

@item -s
@opindex -s
Ignored; for compatibility with other versions of @code{who}.

@item -i
@itemx -u
@itemx --idle
@opindex -i
@opindex -u
@opindex --idle
@cindex idle time
After the login time, print the number of hours and minutes that the
user has been idle.  @samp{.} means the user was active in last minute.
@samp{old} means the user was idle for more than 24 hours.

@item -H
@itemx --heading
@opindex -H
@opindex --heading
Print a line of column headings.

@item -w
@itemx -T
@itemx --mesg
@itemx --message
@itemx --writable
@opindex -w
@opindex -T
@opindex --mesg
@opindex --message
@opindex --writable
@cindex message status
@pindex write@r{, allowed}
After each login name print a character indicating the user's message status:

@display
@samp{+} allowing @code{write} messages
@samp{-} disallowing @code{write} messages
@samp{?} cannot find terminal device
@end display

@end table


@node System context
@chapter System context

@cindex system context
@cindex context, system
@cindex commands for system context

This section describes commands that print or change system-wide
information.

@menu
* date invocation::             Print or set system date and time.
* uname invocation::            Print system information.
* hostname invocation::         Print or set system name.
@end menu


@node date invocation
@section @code{date}: Print or set system date and time

@pindex date
@cindex time, printing or setting
@cindex printing the current time

@code{date} with no arguments prints the current time and date, in
the format of the @samp{%c} directive (described below).

Synopses:

@example
date [@var{option}]@dots{} [+@var{format}]
date [-u|--utc|--universal] @c this avoids a newline in the output
[ @var{MMDDhhmm}[[@var{CC}]@var{YY}][.@var{ss}] ]
@end example

@findex strftime @r{and @code{date}}
@cindex time formats
@cindex formatting times
If given an argument that starts with a @samp{+}, @code{date} prints the
current time and date (or the time and date specified by the
@code{--date} option, see below) in the format defined by that argument,
which is the same as in the @code{strftime} function.  Except for
directives, which start with @samp{%}, characters in the format string
are printed unchanged.  The directives are described below.

@menu
* Time directives::             %[HIklMprsSTXZ]
* Date directives::             %[aAbBcdDhjmUwWxyY]
* Literal directives::          %[%nt]
* Padding::			Pad with zeroes, spaces (%_), or nothing (%-).
* Setting the time::            Changing the system clock.
* Options for date::            Instead of the current time.
* Examples of date::            Examples.
@end menu

@node Time directives
@subsection Time directives

@cindex time directives
@cindex directives, time

@code{date} directives related to times.

@table @samp
@item %H
hour (00@dots{}23)
@item %I
hour (01@dots{}12)
@item %k
hour ( 0@dots{}23)
@item %l
hour ( 1@dots{}12)
@item %M
minute (00@dots{}59)
@item %p
locale's AM or PM
@item %r
time, 12-hour (hh:mm:ss [AP]M)
@item %s
@cindex epoch, seconds since
@cindex seconds since the epoch
@cindex beginning of time
seconds since the epoch, i.e., 1 January 1970 00:00:00 UTC (a
GNU extension)
@item %S
second (00@dots{}61)
@item %T
time, 24-hour (hh:mm:ss)
@item %X
locale's time representation (%H:%M:%S)
@item %Z
timezone (e.g., EDT), or nothing if no timezone is
determinable
@end table


@node Date directives
@subsection Date directives

@cindex date directives
@cindex directives, date

@code{date} directives related to dates.

@table @samp
@item %a
locale's abbreviated weekday name (Sun@dots{}Sat)
@item %A
locale's full weekday name, variable length (Sunday@dots{}Saturday)
@item %b
locale's abbreviated month name (Jan@dots{}Dec)
@item %B
locale's full month name, variable length (January@dots{}December)
@item %c
locale's date and time (Sat Nov 04 12:02:33 EST 1989)
@item %d
day of month (01@dots{}31)
@item %D
date (mm/dd/yy)
@item %h
same as %b
@item %j
day of year (001@dots{}366)
@item %m
month (01@dots{}12)
@item %U
week number of year with Sunday as first day of week (00@dots{}53)
@item %w
day of week (0@dots{}6) with 0 corresponding to Sunday
@item %W
week number of year with Monday as first day of week (00@dots{}53)
@item %x
locale's date representation (mm/dd/yy)
@item %y
last two digits of year (00@dots{}99)
@item %Y
year (1970@dots{}.)
@end table


@node Literal directives
@subsection Literal directives

@cindex literal directives
@cindex directives, literal

@code{date} directives that produce literal strings.

@table @samp
@item %%
a literal %
@item %n
a newline
@item %t
a horizontal tab
@end table


@node Padding
@subsection Padding

@cindex numeric field padding
@cindex padding of numeric fields
@cindex fields, padding numeric

By default, @code{date} pads numeric fields with zeroes, so that, for
example, numeric months are always output as two digits. GNU @code{date}
recognizes the following numeric modifiers between the @samp{%} and the
directive.

@table @samp
@item -
(hyphen) do not pad the field; useful if the output is intended for
human consumption.
@item _
(underscore) pad the field with spaces; useful if you need a fixed
number of characters in the output, but zeroes are too distracting.
@end table

@noindent
These are GNU extensions.

Here is an example illustrating the differences:

@example
date +%d/%m -d "Feb 1"
@result{} 01/02
date +%-d/%-m -d "Feb 1"
@result{} 1/2
date +%_d/%_m -d "Feb 1"
@result{}  1/ 2
@end example


@node Setting the time
@subsection Setting the time

@cindex setting the time
@cindex time setting
@cindex appropriate privileges

If given an argument that does not start with @samp{+}, @code{date} sets
the system clock to the time and date specified by that argument (as
described below).  You must have appropriate privileges to set the
system clock.  The @samp{--date} and @samp{--set} options may not be
used with such an argument.  The @samp{--universal} option may be used
with such an argument to indicate that the specified time and date are
relative to Coordinated Universal Time rather than to the local time
zone.

The argument must consist entirely of digits, which have the following
meaning:

@table @var
@item MM
month
@item DD
day within month
@item hh
hour
@item mm
minute
@item CC
first two digits of year (optional)
@item YY
last two digits of year (optional)
@item ss
second (optional)
@end table

The @samp{--set} option also sets the system clock; see the next section.


@node Options for date
@subsection Options for @code{date}

@cindex @code{date} options
@cindex options for @code{date}

The program accepts the following options.  Also see @ref{Common options}.

@table @samp

@item -d @var{datestr}
@itemx --date=@var{datestr}
@opindex -d
@opindex --date
@cindex parsing date strings
@cindex date strings, parsing
@cindex arbitrary date strings, parsing
@opindex yesterday
@opindex tomorrow
@opindex next @var{day}
@opindex last @var{day}
Display the time and date specified in @var{datestr} instead of the
current time and date.  @var{datestr} can be in almost any common
format.  It can contain month names, timezones, @samp{am} and @samp{pm},
@samp{yesterday}, @samp{ago}, @samp{next}, etc.  @xref{Date input formats}.

@item -r @var{file}
@itemx --reference=@var{file}
@opindex -r
@opindex --reference
Display the time and date as obtained from a reference @var{file},
instead of the current time and date.  Each file has a few timestamps
associated with it.  In this context, the time and date of the last
modification are used.

@item -f @var{datefile}
@itemx --file=@var{datefile}
@opindex -f
@opindex --file
Parse each line in @var{datefile} as with @samp{-d} and display the
resulting time and date.  If @var{datefile} is @samp{-}, use standard
input.  This is useful when you have many dates to process, because the
system overhead of starting up the @code{date} executable many times can
be considerable.

@item -s @var{datestr}
@itemx --set=@var{datestr}
@opindex -s
@opindex --set
Set the time and date to @var{datestr},  See @samp{-d} above.

@item -u
@itemx --utc
@itemx --universal
@opindex -u
@opindex --utc
@opindex --universal
@cindex coordinated universal time
@cindex Greenwich Mean Time
Print or set the time and date in Universal Coordinated Time instead of
in local (wall clock) time.

@end table


@node Examples of date
@subsection Examples of @code{date}

@cindex examples of @code{date}

Here are a few examples.  Also see the documentation for the @samp{-d}
option in the previous section.

@itemize @bullet

@item
To print the date of the day before yesterday:

@example
date --date='2 days ago'
@end example

@item
To print the date of the day three months and one day hence:
@example
date --date='3 months 1 day'
@end example

@item
To print the day of year of Christmas in the current year:
@example
date --date='25 Dec' +%j
@end example

@item
To print the current full month name and the day of the month:
@example
date '+%B %d'
@end example

But this may not be what you want because for the first nine days of
the month, the @samp{%d} expands to a zero-padded two-digit field,
for example @samp{date -d 1may '+%B %d'} will print @samp{May 01}.

@item
To print a date without the leading zero for one-digit days
of the month, you can use the (GNU extension) @code{-} modifier to suppress
the padding altogether.
@example
date -d=1may '+%B %-d'
@end example

@item
To print the current date and time in the format required by many
non-GNU versions of @code{date} when setting the system clock:
@example
date +%m%d%H%M%Y.%S
@end example

@item
To set the system clock forward by two minutes:
@example
date --set='+2 minutes'
@end example

@end itemize


@node uname invocation
@section @code{uname}: Print system information

@pindex uname
@cindex print system information
@cindex system information, printing

@code{uname} prints information about the machine and operating system
it is run on.  If no options are given, @code{uname} acts as if the
@code{-s} option were given.

Synopsis:

@example
uname [@var{option}]@dots{}
@end example

If multiple options or @code{-a} are given, the selected information is
printed in this order:

@example
@var{sysname} @var{nodename} @var{release} @var{osversion} @var{machine}
@end example

The @var{osversion}, at least, may well be multiple words.  For example:

@example
uname -a
@result{} Linux hayley 1.0.4 #3 Thu May 12 18:06:34 1994 i486
@end example


The program accepts the following options.  Also see @ref{Common options}.

@table @samp

@item -a
@itemx --all
@opindex -a
@opindex --all
Print all of the below information.

@item -m
@itemx --machine
@opindex -m
@opindex --machine
@cindex machine type
@cindex hardware type
Print the machine (hardware) type.

@item -n
@itemx --nodename
@opindex -n
@opindex --nodename
@cindex hostname
@cindex node name
@cindex network node name
Print the machine's network node hostname.

@item -r
@itemx --release
@opindex -r
@opindex --release
@cindex operating system release
@cindex release of operating system
Print the operating system release.

@item -s
@itemx --sysname
@opindex -s
@opindex --sysname
@cindex operating system name
@cindex name of operating system
Print the operating system name.

@item -v
@opindex -v
@cindex operating system version
@cindex version of operating system
Print the operating system version.

@end table


@node hostname invocation
@section @code{hostname}: Print or set system name

@pindex hostname
@cindex setting the hostname
@cindex printing the hostname
@cindex system name, printing
@cindex appropriate privileges

With no arguments, @code{hostname} prints the name of the current host
system.  With one argument, it sets the current host name to the
specified string.  You must have appropriate privileges to set the host
name.

Synopsis:

@example
hostname [@var{name}]
@end example

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node Modified command invocation
@chapter Modified command invocation

@cindex modified command invocation
@cindex invocation of commands, modified
@cindex commands for invoking other commands

This section describes commands that run other commands in some context
different than the current one: a modified environment, as a different
user, etc.

@menu
* env invocation::              Modify environment variables.
* nice invocation::             Modify scheduling priority.
* nohup invocation::            Immunize to hangups.
* su invocation::               Modify user and group id.
@end menu


@node env invocation
@section @code{env}: Run a command in a modified environment

@pindex env
@cindex environment, running a program in a modified
@cindex modified environment, running a program in

@code{env} runs a command with an environment modified as specified
by the command line arguments.

Synopses:

@example
env [@var{option}]@dots{} [@var{name}=@var{value}]@dots{} @c
[@var{command} [@var{args}]@dots{}]
env
@end example

Arguments of the form @samp{@var{variable}=@var{value}} set
the environment variable @var{variable} to value @var{value}.
@var{value} may be empty (@samp{@var{variable}=}).  Setting a variable
to an empty value is different from unsetting it.

@vindex PATH
The first remaining argument specifies the program name to invoke; it is
searched for according to the @code{PATH} environment variable.  Any
remaining arguments are passed as arguments to that program.

@cindex environment, printing

If no command name is specified following the environment
specifications, the resulting environment is printed.  This is like
specifying a command name of @code{printenv}.

The program accepts the following options.  Also see @ref{Common options}.

@table @samp

@item -u @var{name}
@itemx --unset=@var{name}
@opindex -u
@opindex -unset
Remove variable @var{name} from the environment, if it was in the
environment.

@item -
@itemx -i
@itemx --ignore-environment
@opindex -
@opindex -i
@opindex --ignore-environment
Start with an empty environment, ignoring the inherited environment.

@end table


@node nice invocation
@section @code{nice}: Run a command with modified scheduling priority

@pindex nice
@cindex modifying scheduling priority
@cindex scheduling priority, modifying
@cindex priority, modifying
@cindex appropriate privileges

If no arguments are given, @code{nice} prints the current scheduling
priority, which it inherited.  Otherwise, @code{nice} runs the given
@var{command} with its scheduling priority adjusted.  If no
@var{adjustment} is given, the priority of the command is incremented by
10.  You must have appropriate privileges to specify a negative
adjustment.  The priority can be adjusted by @code{nice} over the range
of -20 (the highest priority) to 19 (the lowest).

Synopsis:

@example
nice [@var{option}]@dots{} [@var{command} [@var{arg}]@dots{}]
@end example

@cindex conflicts with shell built-ins
@cindex built-in shell commands, conflicts with
Because most shells have a built-in command by the same name, using the
unadorned command name in a script or interactively may get you
different functionality than that described here.

The program accepts the following option.  Also see @ref{Common options}.

@table @samp
@item -n @var{adjustment}
@itemx -@var{adjustment}
@itemx --adjustment=@var{adjustment}
@opindex -n
@opindex --adjustment
@opindex -@var{adjustment}
Add @var{adjustment} instead of 10 to the command's priority.
@end table


@node nohup invocation
@section @code{nohup}: Run a command immune to hangups

@pindex nohup
@cindex hangups, immunity to
@cindex immunity to hangups

@flindex nohup.out
@code{nohup} runs the given @var{command} with hangup signals ignored,
so that the command can continue running in the background after you log
out.

Synopsis:

@example
nohup @var{command} [@var{arg}]@dots{}
@end example

@flindex nohup.out
Also, the scheduling priority is increased by 5.  If standard output is a
tty, it and standard error are redirected so that they are appended to
the file @file{nohup.out}; if that cannot be written to, they are
appended to the file @file{$HOME/nohup.out}.  If that cannot be written
to, the command is not run.

If @code{nohup} creates either @file{nohup.out} or
@file{$HOME/nohup.out}, it creates it with no ``group'' or ``other''
access permissions.  It does not change the permissions if the output
file already existed.

@code{nohup} does not automatically put the command it runs in the
background; you must do that explicitly, by ending the command line
with an @samp{&}.

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node su invocation
@section @code{su}: Run a command with substitute user and group id

@pindex su
@cindex substitute user and group ids
@cindex user id, switching
@cindex super-user, becoming
@cindex root, becoming

@code{su} allows one user to temporarily become another user.  It runs a
command (often an interactive shell) with the real and effective user
id, group id, and supplemental groups of a given @var{user}.

Synopsis:

@example
su [@var{option}]@dots{} [@var{user} [@var{arg}]@dots{}]
@end example

@cindex passwd entry, and @code{su} shell
@flindex /bin/sh
@flindex /etc/passwd
If no @var{user} is given, the default is @code{root}, the super-user.
The shell to use is taken from @var{user}'s @code{passwd} entry, or
@file{/bin/sh} if none is specified there.  If @var{user} has a
password, @code{su} prompts for the password unless run by a user with
effective user id of zero (the super-user).

@vindex HOME
@vindex SHELL
@vindex USER
@vindex LOGNAME
@cindex login shell
By default, @code{su} does not change the current directory.
It sets the environment variables @code{HOME} and @code{SHELL}
from the password entry for @var{user}, and if @var{user} is not
the super-user, sets @code{USER} and @code{LOGNAME} to @var{user}.
By default, the shell is not a login shell.

Any additional @var{arg}s are passed as additional arguments to the
shell.

@cindex @samp{-su}
GNU @code{su} does not treat @file{/bin/sh} or any other shells specially
(e.g., by setting @code{argv[0]} to @samp{-su}, passing @code{-c} only
to certain shells, etc.).

@findex syslog
@code{su} can optionally be compiled to use @code{syslog} to report
failed, and optionally successful, @code{su} attempts.  (If the system
supports @code{syslog}.)  However, GNU @code{su} does not check if the
user is a member of the @code{wheel} group; see below.

The program accepts the following options.  Also see @ref{Common options}.

@table @samp
@item -c @var{command}
@itemx --command=@var{command}
@opindex -c
@opindex --command
Pass @var{command}, a single command line to run, to the shell with
a @code{-c} option instead of starting an interactive shell.

@item -f
@itemx --fast
@opindex -f
@opindex --fast
@flindex .cshrc
@cindex file name pattern expansion, disabled
@cindex globbing, disabled
Pass the @code{-f} option to the shell.  This probably only makes sense
if the shell run is @code{csh} or @code{tcsh}, for which the @code{-f}
option prevents reading the startup file (@file{.cshrc}).  With
Bourne-like shells, the @code{-f} option disables file name pattern
expansion (globbing), which is not likely to be useful.

@item -
@itemx -l
@itemx --login
@opindex -
@opindex -l
@opindex --login
@c other variables already indexed above
@vindex TERM
@vindex PATH
@cindex login shell, creating
Make the shell a login shell.  This means the following.  Unset all
environment variables except @code{TERM}, @code{HOME}, and @code{SHELL}
(which are set as described above), and @code{USER} and @code{LOGNAME}
(which are set, even for the super-user, as described above), and set
@code{PATH} to a compiled-in default value.  Change to @var{user}'s home
directory.  Prepend @samp{-} to the shell's name, intended to make it
read its login startup file(s).

@item -m
@itemx -p
@itemx --preserve-environment
@opindex -m
@opindex -p
@opindex --preserve-environment
@cindex environment, preserving
@flindex /etc/shells
@cindex restricted shell
Do not change the environment variables @code{HOME}, @code{USER},
@code{LOGNAME}, or @code{SHELL}.  Run the shell given in the environment
variable @code{SHELL} instead of the shell from @var{user}'s passwd
entry, unless the user running @code{su} is not the superuser and
@var{user}'s shell is restricted.  A @dfn{restricted shell} is one that
is not listed in the file @file{/etc/shells}, or in a compiled-in list
if that file does not exist.  Parts of what this option does can be
overridden by @code{--login} and @code{--shell}.

@item -s @var{shell}
@itemx --shell=@var{shell}
@opindex -s
@opindex --shell
Run @var{shell} instead of the shell from @var{user}'s passwd entry,
unless the user running @code{su} is not the superuser and @var{user}'s
shell is restricted (see @samp{-m} just above).

@end table

@cindex wheel group, not supported
@cindex group wheel, not supported
@cindex fascism
@heading Why GNU @code{su} does not support the @samp{wheel} group

(This section is by Richard Stallman.)

@cindex Twenex
@cindex MIT AI lab
Sometimes a few of the users try to hold total power over all the
rest.  For example, in 1984, a few users at the MIT AI lab decided to
seize power by changing the operator password on the Twenex system and
keeping it secret from everyone else.  (I was able to thwart this coup
and give power back to the users by patching the kernel, but I
wouldn't know how to do that in Unix.)

However, occasionally the rulers do tell someone.  Under the usual
@code{su} mechanism, once someone learns the root password who
sympathizes with the ordinary users, he or she can tell the rest.  The
``wheel group'' feature would make this impossible, and thus cement the
power of the rulers.

I'm on the side of the masses, not that of the rulers.  If you are
used to supporting the bosses and sysadmins in whatever they do, you
might find this idea strange at first.


@node Delaying
@chapter Delaying

@cindex delaying commands
@cindex commands for delaying

Perhaps @code{wait} or other commands should be described here also?

@menu
* sleep invocation::            Delay for a specified time.
@end menu


@node sleep invocation
@section @code{sleep}: Delay for a specified time

@pindex sleep
@cindex delay for a specified time

@code{sleep} pauses for an amount of time specified by the sum of
the values of the command line arguments.

Synopsis:

@example
sleep [@var{number}[smhd]]@dots{}
@end example

@cindex time units
Each argument is a number followed by an optional unit; the default
is seconds.  The units are:

@table @samp
@item s
seconds
@item m
minutes
@item h
hours
@item d
days
@end table

The only options are @samp{--help} and @samp{--version}.  @xref{Common
options}.


@node Index
@unnumbered Index

@printindex cp

@contents
@bye

@c Local variables:
@c texinfo-column-for-description: 33
@c End: