mirrored from git://git.sv.gnu.org/coreutils.git
/
coreutils.texi
20177 lines (16390 loc) · 647 KB
/
coreutils.texi
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
\input texinfo
@c %**start of header
@setfilename coreutils.info
@include version.texi
@settitle GNU Coreutils @value{VERSION}
@documentencoding UTF-8
@set txicodequoteundirected
@set txicodequotebacktick
@allowcodebreaks false
@c %**end of header
@include constants.texi
@c Define new indices.
@defcodeindex op
@defcodeindex fl
@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
@dircategory Basics
@direntry
* Coreutils: (coreutils). Core GNU (file, text, shell) utilities.
* Common options: (coreutils)Common options.
* File permissions: (coreutils)File permissions. Access modes.
* Date input formats: (coreutils)Date input formats.
@end direntry
@c FIXME: the following need documentation
@c * [: (coreutils)[ invocation. File/string tests.
@c * pinky: (coreutils)pinky invocation. FIXME.
@dircategory Individual utilities
@direntry
* arch: (coreutils)arch invocation. Print machine hardware name.
* b2sum: (coreutils)b2sum invocation. Print or check BLAKE2 digests.
* base32: (coreutils)base32 invocation. Base32 encode/decode data.
* base64: (coreutils)base64 invocation. Base64 encode/decode data.
* basename: (coreutils)basename invocation. Strip directory and suffix.
* basenc: (coreutils)basenc invocation. Encoding/decoding of data.
* cat: (coreutils)cat invocation. Concatenate and write files.
* chcon: (coreutils)chcon invocation. Change SELinux CTX of files.
* chgrp: (coreutils)chgrp invocation. Change file groups.
* chmod: (coreutils)chmod invocation. Change access permissions.
* chown: (coreutils)chown invocation. Change file owners and groups.
* chroot: (coreutils)chroot invocation. Specify the root directory.
* cksum: (coreutils)cksum invocation. Print POSIX CRC checksum.
* comm: (coreutils)comm invocation. Compare sorted files by line.
* cp: (coreutils)cp invocation. Copy files.
* csplit: (coreutils)csplit invocation. Split by context.
* cut: (coreutils)cut invocation. Print selected parts of lines.
* date: (coreutils)date invocation. Print/set system date and time.
* dd: (coreutils)dd invocation. Copy and convert a file.
* df: (coreutils)df invocation. Report file system usage.
* dir: (coreutils)dir invocation. List directories briefly.
* dircolors: (coreutils)dircolors invocation. Color setup for ls.
* dirname: (coreutils)dirname invocation. Strip last file name component.
* du: (coreutils)du invocation. Report file usage.
* echo: (coreutils)echo invocation. Print a line of text.
* env: (coreutils)env invocation. Modify the environment.
* expand: (coreutils)expand invocation. Convert tabs to spaces.
* expr: (coreutils)expr invocation. Evaluate expressions.
* factor: (coreutils)factor invocation. Print prime factors
* false: (coreutils)false invocation. Do nothing, unsuccessfully.
* fmt: (coreutils)fmt invocation. Reformat paragraph text.
* fold: (coreutils)fold invocation. Wrap long input lines.
* groups: (coreutils)groups invocation. Print group names a user is in.
* head: (coreutils)head invocation. Output the first part of files.
* hostid: (coreutils)hostid invocation. Print numeric host identifier.
* hostname: (coreutils)hostname invocation. Print or set system name.
* id: (coreutils)id invocation. Print user identity.
* install: (coreutils)install invocation. Copy files and set attributes.
* join: (coreutils)join invocation. Join lines on a common field.
* kill: (coreutils)kill invocation. Send a signal to processes.
* link: (coreutils)link invocation. Make hard links between files.
* ln: (coreutils)ln invocation. Make links between files.
* logname: (coreutils)logname invocation. Print current login name.
* ls: (coreutils)ls invocation. List directory contents.
* md5sum: (coreutils)md5sum invocation. Print or check MD5 digests.
* mkdir: (coreutils)mkdir invocation. Create directories.
* mkfifo: (coreutils)mkfifo invocation. Create FIFOs (named pipes).
* mknod: (coreutils)mknod invocation. Create special files.
* mktemp: (coreutils)mktemp invocation. Create temporary files.
* mv: (coreutils)mv invocation. Rename files.
* nice: (coreutils)nice invocation. Modify niceness.
* nl: (coreutils)nl invocation. Number lines and write files.
* nohup: (coreutils)nohup invocation. Immunize to hangups.
* nproc: (coreutils)nproc invocation. Print the number of processors.
* numfmt: (coreutils)numfmt invocation. Reformat numbers.
* od: (coreutils)od invocation. Dump files in octal, etc.
* paste: (coreutils)paste invocation. Merge lines of files.
* pathchk: (coreutils)pathchk invocation. Check file name portability.
* pr: (coreutils)pr invocation. Paginate or columnate files.
* printenv: (coreutils)printenv invocation. Print environment variables.
* printf: (coreutils)printf invocation. Format and print data.
* ptx: (coreutils)ptx invocation. Produce permuted indexes.
* pwd: (coreutils)pwd invocation. Print working directory.
* readlink: (coreutils)readlink invocation. Print referent of a symlink.
* realpath: (coreutils)realpath invocation. Print resolved file names.
* rm: (coreutils)rm invocation. Remove files.
* rmdir: (coreutils)rmdir invocation. Remove empty directories.
* runcon: (coreutils)runcon invocation. Run in specified SELinux CTX.
* seq: (coreutils)seq invocation. Print numeric sequences
* sha1sum: (coreutils)sha1sum invocation. Print or check SHA-1 digests.
* sha2: (coreutils)sha2 utilities. Print or check SHA-2 digests.
* shred: (coreutils)shred invocation. Remove files more securely.
* shuf: (coreutils)shuf invocation. Shuffling text files.
* sleep: (coreutils)sleep invocation. Delay for a specified time.
* sort: (coreutils)sort invocation. Sort text files.
* split: (coreutils)split invocation. Split into pieces.
* stat: (coreutils)stat invocation. Report file(system) status.
* stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering.
* stty: (coreutils)stty invocation. Print/change terminal settings.
* sum: (coreutils)sum invocation. Print traditional checksum.
* sync: (coreutils)sync invocation. Sync files to stable storage.
* tac: (coreutils)tac invocation. Reverse files.
* tail: (coreutils)tail invocation. Output the last part of files.
* tee: (coreutils)tee invocation. Redirect to multiple files.
* test: (coreutils)test invocation. File/string tests.
* timeout: (coreutils)timeout invocation. Run with time limit.
* touch: (coreutils)touch invocation. Change file timestamps.
* tr: (coreutils)tr invocation. Translate characters.
* true: (coreutils)true invocation. Do nothing, successfully.
* truncate: (coreutils)truncate invocation. Shrink/extend size of a file.
* tsort: (coreutils)tsort invocation. Topological sort.
* tty: (coreutils)tty invocation. Print terminal name.
* uname: (coreutils)uname invocation. Print system information.
* unexpand: (coreutils)unexpand invocation. Convert spaces to tabs.
* uniq: (coreutils)uniq invocation. Uniquify files.
* unlink: (coreutils)unlink invocation. Removal via unlink(2).
* uptime: (coreutils)uptime invocation. Print uptime and load.
* users: (coreutils)users invocation. Print current user names.
* vdir: (coreutils)vdir invocation. List directories verbosely.
* wc: (coreutils)wc invocation. Line, word, and byte counts.
* who: (coreutils)who invocation. Print who is logged in.
* whoami: (coreutils)whoami invocation. Print effective user ID.
* yes: (coreutils)yes invocation. Print a string indefinitely.
@end direntry
@copying
This manual documents version @value{VERSION} of the GNU core
utilities, including the standard programs for text and file manipulation.
Copyright @copyright{} 1994--2024 Free Software Foundation, Inc.
@quotation
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, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end quotation
@end copying
@titlepage
@title GNU @code{Coreutils}
@subtitle Core GNU utilities
@subtitle for version @value{VERSION}, @value{UPDATED}
@author David MacKenzie et al.
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@shortcontents
@contents
@ifnottex
@node Top
@top GNU Coreutils
@insertcopying
@end ifnottex
@cindex core utilities
@cindex text utilities
@cindex shell utilities
@cindex file utilities
@menu
* Introduction:: Caveats, overview, and authors
* Common options:: Common options
* Output of entire files:: cat tac nl od base32 base64 basenc
* Formatting file contents:: fmt pr fold
* Output of parts of files:: head tail split csplit
* Summarizing files:: wc sum cksum b2sum md5sum sha1sum sha2
* Operating on sorted files:: sort shuf uniq comm ptx tsort
* Operating on fields:: cut paste join
* Operating on characters:: tr expand unexpand
* Directory listing:: ls dir vdir dircolors
* Basic operations:: cp dd install mv rm shred
* Special file types:: mkdir rmdir unlink mkfifo mknod ln link readlink
* Changing file attributes:: chgrp chmod chown touch
* File space usage:: df du stat sync truncate
* Printing text:: echo printf yes
* Conditions:: false true test expr
* Redirection:: tee
* File name manipulation:: dirname basename pathchk mktemp realpath
* Working context:: pwd stty printenv tty
* User information:: id logname whoami groups users who
* System context:: date arch nproc uname hostname hostid uptime
* SELinux context:: chcon runcon
* Modified command invocation:: chroot env nice nohup stdbuf timeout
* Process control:: kill
* Delaying:: sleep
* Numeric operations:: factor numfmt seq
* File permissions:: Access modes
* File timestamps:: File timestamp issues
* Date input formats:: Specifying date strings
* Version sort ordering:: Details on version-sort algorithm
* Opening the software toolbox:: The software tools philosophy
* GNU Free Documentation License:: Copying and sharing this manual
* Concept index:: General index
@detailmenu
--- The Detailed Node Listing ---
Common Options
* Exit status:: Indicating program success or failure
* Backup options:: Backup options
* Block size:: Block size
* Floating point:: Floating point number representation
* Signal specifications:: Specifying signals
* Disambiguating names and IDs:: chgrp, chown, chroot, id: user and group syntax
* Random sources:: Sources of random data
* Target directory:: Target directory
* Trailing slashes:: Trailing slashes
* Traversing symlinks:: Traversing symlinks to directories
* Treating / specially:: Treating / specially
* Standards conformance:: Standards conformance
* Multi-call invocation:: Multi-call program invocation
Output of entire files
* cat invocation:: Concatenate and write files
* tac invocation:: Concatenate and write files in reverse
* nl invocation:: Number lines and write files
* od invocation:: Write files in octal or other formats
* base32 invocation:: Transform data into printable data
* base64 invocation:: Transform data into printable data
* basenc invocation:: Transform data into printable data
Formatting file contents
* fmt invocation:: Reformat paragraph text
* pr invocation:: Paginate or columnate files for printing
* fold invocation:: Wrap input lines to fit in specified width
Output of parts of files
* head invocation:: Output the first part of files
* tail invocation:: Output the last part of files
* split invocation:: Split a file into fixed-size pieces
* csplit invocation:: Split a file into context-determined pieces
Summarizing files
* wc invocation:: Print newline, word, and byte counts
* sum invocation:: Print checksum and block counts
* cksum invocation:: Print CRC checksum and byte counts
* md5sum invocation:: Print or check MD5 digests
* b2sum invocation:: Print or check BLAKE2 digests
* sha1sum invocation:: Print or check SHA-1 digests
* sha2 utilities:: Print or check SHA-2 digests
Operating on sorted files
* sort invocation:: Sort text files
* shuf invocation:: Shuffle text files
* uniq invocation:: Uniquify files
* comm invocation:: Compare two sorted files line by line
* ptx invocation:: Produce a permuted index of file contents
* tsort invocation:: Topological sort
@command{ptx}: Produce permuted indexes
* General options in ptx:: Options which affect general program behavior
* Charset selection in ptx:: Underlying character set considerations
* Input processing in ptx:: Input fields, contexts, and keyword selection
* Output formatting in ptx:: Types of output format, and sizing the fields
* Compatibility in ptx:: The GNU extensions to @command{ptx}
Operating on fields
* cut invocation:: Print selected parts of lines
* paste invocation:: Merge lines of files
* join invocation:: Join lines on a common field
Operating on characters
* tr invocation:: Translate, squeeze, and/or delete characters
* expand invocation:: Convert tabs to spaces
* unexpand invocation:: Convert spaces to tabs
@command{tr}: Translate, squeeze, and/or delete characters
* Character arrays:: Specifying arrays of characters
* Translating:: Changing one set of characters to another
* Squeezing and deleting:: Removing characters
Directory listing
* ls invocation:: List directory contents
* dir invocation:: Briefly list directory contents
* vdir invocation:: Verbosely list directory contents
* dircolors invocation:: Color setup for @command{ls}
@command{ls}: List directory contents
* Which files are listed:: Which files are listed
* What information is listed:: What information is listed
* Sorting the output:: Sorting the output
* General output formatting:: General output formatting
* Formatting the file names:: Formatting the file names
Basic operations
* cp invocation:: Copy files and directories
* dd invocation:: Convert and copy a file
* install invocation:: Copy files and set attributes
* mv invocation:: Move (rename) files
* rm invocation:: Remove files or directories
* shred invocation:: Remove files more securely
Special file types
* link invocation:: Make a hard link via the link syscall
* ln invocation:: Make links between files
* mkdir invocation:: Make directories
* mkfifo invocation:: Make FIFOs (named pipes)
* mknod invocation:: Make block or character special files
* readlink invocation:: Print value of a symlink or canonical file name
* rmdir invocation:: Remove empty directories
* unlink invocation:: Remove files via unlink syscall
Changing file attributes
* chown invocation:: Change file owner and group
* chgrp invocation:: Change group ownership
* chmod invocation:: Change access permissions
* touch invocation:: Change file timestamps
File space usage
* df invocation:: Report file system space usage
* du invocation:: Estimate file space usage
* stat invocation:: Report file or file system status
* sync invocation:: Synchronize cached writes to persistent storage
* truncate invocation:: Shrink or extend the size of a file
Printing text
* echo invocation:: Print a line of text
* printf invocation:: Format and print data
* yes invocation:: Print a string until interrupted
Conditions
* false invocation:: Do nothing, unsuccessfully
* true invocation:: Do nothing, successfully
* test invocation:: Check file types and compare values
* expr invocation:: Evaluate expressions
@command{test}: Check file types and compare values
* File type tests:: File type tests
* Access permission tests:: Access permission tests
* File characteristic tests:: File characteristic tests
* String tests:: String tests
* Numeric tests:: Numeric tests
@command{expr}: Evaluate expression
* String expressions:: @code{+ : match substr index length}
* Numeric expressions:: @code{+ - * / %}
* Relations for expr:: @code{| & < <= = == != >= >}
* Examples of expr:: Examples of using @command{expr}
Redirection
* tee invocation:: Redirect output to multiple files or processes
File name manipulation
* basename invocation:: Strip directory and suffix from a file name
* dirname invocation:: Strip last file name component
* pathchk invocation:: Check file name validity and portability
* mktemp invocation:: Create temporary file or directory
* realpath invocation:: Print resolved file names
Working context
* pwd invocation:: Print working directory
* stty invocation:: Print or change terminal characteristics
* printenv invocation:: Print all or some environment variables
* tty invocation:: Print file name of terminal on standard input
@command{stty}: Print or change terminal characteristics
* Control:: Control settings
* Input:: Input settings
* Output:: Output settings
* Local:: Local settings
* Combination:: Combination settings
* Characters:: Special characters
* Special:: Special settings
User information
* id invocation:: Print user identity
* 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
System context
* arch invocation:: Print machine hardware name
* date invocation:: Print or set system date and time
* nproc invocation:: Print the number of processors
* uname invocation:: Print system information
* hostname invocation:: Print or set system name
* hostid invocation:: Print numeric host identifier
* uptime invocation:: Print system uptime and load
@command{date}: Print or set system date and time
* Time conversion specifiers:: %[HIklMNpPrRsSTXzZ]
* Date conversion specifiers:: %[aAbBcCdDeFgGhjmuUVwWxyY]
* Literal conversion specifiers:: %[%nt]
* Padding and other flags:: Pad with zeros, spaces, etc.
* Setting the time:: Changing the system clock
* Options for date:: Instead of the current time
* Date input formats:: Specifying date strings
* Examples of date:: Examples
SELinux context
* chcon invocation:: Change SELinux context of file
* runcon invocation:: Run a command in specified SELinux context
Modified command invocation
* chroot invocation:: Run a command with a different root directory
* env invocation:: Run a command in a modified environment
* nice invocation:: Run a command with modified niceness
* nohup invocation:: Run a command immune to hangups
* stdbuf invocation:: Run a command with modified I/O buffering
* timeout invocation:: Run a command with a time limit
Process control
* kill invocation:: Sending a signal to processes.
Delaying
* sleep invocation:: Delay for a specified time
Numeric operations
* factor invocation:: Print prime factors
* numfmt invocation:: Reformat numbers
* seq invocation:: Print numeric sequences
File timestamps
* File timestamps:: File timestamp issues
File permissions
* Mode Structure:: Structure of file mode bits
* Symbolic Modes:: Mnemonic representation of file mode bits
* Numeric Modes:: File mode bits as octal numbers
* Directory Setuid and Setgid:: Set-user-ID and set-group-ID on directories
Date input formats
* General date syntax:: Common rules
* Calendar date items:: @samp{14 Nov 2022}
* Time of day items:: @samp{9:02pm}
* Time zone items:: @samp{UTC}, @samp{-0700}, @samp{+0900}, @dots{}
* Combined date and time of day items:: @samp{2022-11-14T21:02:42,000000-0500}
* Day of week items:: @samp{Monday} and others
* Relative items in date strings:: @samp{next tuesday, 2 years ago}
* Pure numbers in date strings:: @samp{20221114}, @samp{2102}
* Seconds since the Epoch:: @samp{@@1668477762}
* Specifying time zone rules:: @samp{TZ="America/New_York"}, @samp{TZ="UTC0"}
* Authors of parse_datetime:: Bellovin, Eggert, Salz, Berets, et al.
Version sorting order
* Version sort overview::
* Version sort implementation::
* Differences from Debian version sort::
* Advanced version sort topics::
Opening the software toolbox
* Toolbox introduction:: Toolbox introduction
* I/O redirection:: I/O redirection
* The who command:: The @command{who} command
* The cut command:: The @command{cut} command
* The sort command:: The @command{sort} command
* The uniq command:: The @command{uniq} command
* Putting the tools together:: Putting the tools together
Copying This Manual
* GNU Free Documentation License:: Copying and sharing this manual
@end detailmenu
@end menu
@node Introduction
@chapter Introduction
This manual is a work in progress: many sections make no attempt to explain
basic concepts in a way suitable for novices. Thus, if you are interested,
please get involved in improving this manual. The entire GNU community
will benefit.
@cindex POSIX
The GNU utilities documented here are mostly compatible with the
POSIX standard.
@cindex bugs, reporting
Please report bugs to @email{bug-coreutils@@gnu.org}.
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.
If you have a problem with @command{sort} or @command{date}, try using the
@option{--debug} option, as it can often help find and fix problems without
having to wait for an answer to a bug report. If the debug output
does not suffice to fix the problem on your own, please compress and
attach it to the rest of your bug report.
Although diffs are welcome,
please include a description of the problem as well, since this is
sometimes difficult to infer. @xref{Bugs, , , gcc, Using and Porting GNU CC}.
@cindex Berry, K.
@cindex Paterson, R.
@cindex Stallman, R.
@cindex Pinard, F.
@cindex MacKenzie, D.
@cindex Meyering, J.
@cindex Youmans, B.
This manual was originally derived from the Unix man pages in the
distributions, which were written by David MacKenzie and updated by Jim
Meyering. What you are reading now is the authoritative documentation
for these utilities; the man pages are no longer being maintained. The
original @command{fmt} man page was written by Ross Paterson. Fran@,{c}ois
Pinard did the initial conversion to Texinfo format. Karl Berry did the
indexing, some reorganization, and editing of the results. Brian
Youmans of the Free Software Foundation office staff combined the
manuals for textutils, fileutils, and sh-utils to produce the present
omnibus manual. Richard Stallman contributed his usual invaluable
insights to the overall process.
@node Common options
@chapter Common options
@macro optBackup
@item -b
@itemx --backup[=@var{method}]
@opindex -b
@opindex --backup
@vindex VERSION_CONTROL
@cindex backups, making
@xref{Backup options}.
Make a backup of each file that would otherwise be overwritten or removed.
@end macro
@macro optBackupSuffix
@item -S @var{suffix}
@itemx --suffix=@var{suffix}
@opindex -S
@opindex --suffix
Append @var{suffix} to each backup file made with @option{-b}.
@xref{Backup options}.
@end macro
@macro optTargetDirectory
@item -t @var{directory}
@itemx --target-directory=@var{directory}
@opindex -t
@opindex --target-directory
@cindex target directory
@cindex destination directory
Specify the destination @var{directory}.
@xref{Target directory}.
@end macro
@macro optNoTargetDirectory
@item -T
@itemx --no-target-directory
@opindex -T
@opindex --no-target-directory
@cindex target directory
@cindex destination directory
Do not treat the last operand specially when it is a directory or a
symbolic link to a directory. @xref{Target directory}.
@end macro
@macro outputNUL
@cindex output NUL-byte-terminated lines
Output a zero byte (ASCII NUL) at the end of each line,
rather than a newline. This option enables other programs to parse the
output even when that output would contain data with embedded newlines.
@end macro
@macro optNull
@item -0
@itemx --null
@opindex -0
@opindex --null
@outputNUL
@end macro
@macro optZero
@item -z
@itemx --zero
@opindex -z
@opindex --zero
@outputNUL
@end macro
@macro optZeroTerminated
@item -z
@itemx --zero-terminated
@opindex -z
@opindex --zero-terminated
@cindex process zero-terminated items
Delimit items with a zero byte rather than a newline (ASCII LF).
I.e., treat input as items separated by ASCII NUL
and terminate output items with ASCII NUL.
This option can be useful in conjunction with @samp{perl -0} or
@samp{find -print0} and @samp{xargs -0} which do the same in order to
reliably handle arbitrary file names (even those containing blanks
or other special characters).
@end macro
@macro optSi
@item --si
@opindex --si
@cindex SI output
Append an SI-style abbreviation to each size, such as @samp{M} for
megabytes. Powers of 1000 are used, not 1024; @samp{M} stands for
1,000,000 bytes. This option is equivalent to
@option{--block-size=si}. Use the @option{-h} or
@option{--human-readable} option if
you prefer powers of 1024.
@end macro
@macro optHumanReadable
@item -h
@itemx --human-readable
@opindex -h
@opindex --human-readable
@cindex human-readable output
Append a size letter to each size, such as @samp{M} for mebibytes.
Powers of 1024 are used, not 1000; @samp{M} stands for 1,048,576 bytes.
This option is equivalent to @option{--block-size=human-readable}.
Use the @option{--si} option if you prefer powers of 1000.
@end macro
@macro optStripTrailingSlashes
@item --strip-trailing-slashes
@opindex --strip-trailing-slashes
@cindex stripping trailing slashes
Remove any trailing slashes from each @var{source} argument.
@xref{Trailing slashes}.
@end macro
@macro mayConflictWithShellBuiltIn{cmd}
@cindex conflicts with shell built-ins
@cindex built-in shell commands, conflicts with
Due to shell aliases and built-in @command{\cmd\} functions, using an
unadorned @command{\cmd\} interactively or in a script may get you
different functionality than that described here. Invoke it via
@command{env} (i.e., @code{env \cmd\ @dots{}}) to avoid interference
from the shell.
@end macro
@macro multiplierSuffixes{varName}
@var{\varName\} may be, or may be an integer optionally followed by,
one of the following multiplicative suffixes:
@example
@samp{b} => 512 ("blocks")
@samp{KB} => 1000 (KiloBytes)
@samp{K} => 1024 (KibiBytes)
@samp{MB} => 1000*1000 (MegaBytes)
@samp{M} => 1024*1024 (MebiBytes)
@samp{GB} => 1000*1000*1000 (GigaBytes)
@samp{G} => 1024*1024*1024 (GibiBytes)
@end example
and so on for @samp{T}, @samp{P}, @samp{E}, @samp{Z}, @samp{Y},
@samp{R}, and @samp{Q}.
Binary prefixes can be used, too: @samp{KiB}=@samp{K}, @samp{MiB}=@samp{M},
and so on.
@end macro
@c FIXME: same as above, but no ``blocks'' line.
@macro multiplierSuffixesNoBlocks{varName}
@var{\varName\} may be, or may be an integer optionally followed by,
one of the following multiplicative suffixes:
@example
@samp{KB} => 1000 (KiloBytes)
@samp{K} => 1024 (KibiBytes)
@samp{MB} => 1000*1000 (MegaBytes)
@samp{M} => 1024*1024 (MebiBytes)
@samp{GB} => 1000*1000*1000 (GigaBytes)
@samp{G} => 1024*1024*1024 (GibiBytes)
@end example
and so on for @samp{T}, @samp{P}, @samp{E}, @samp{Z}, @samp{Y},
@samp{R}, and @samp{Q}.
Binary prefixes can be used, too: @samp{KiB}=@samp{K}, @samp{MiB}=@samp{M},
and so on.
@end macro
@cindex common options
Certain options are available in all of 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.)
@vindex POSIXLY_CORRECT
Normally options and operands can appear in any order, and programs act
as if all the options appear before any operands. For example,
@samp{sort -r passwd -t :} acts like @samp{sort -r -t : passwd}, since
@samp{:} is an option-argument of @option{-t}. However, if the
@env{POSIXLY_CORRECT} environment variable is set, options must appear
before operands, unless otherwise specified for a particular command.
A few programs can usefully have trailing operands with leading
@samp{-}. With such a program, options must precede operands even if
@env{POSIXLY_CORRECT} is not set, and this fact is noted in the
program description. For example, the @command{env} command's options
must appear before its operands, since in some cases the operands
specify a command that itself contains options.
Most programs that accept long options recognize unambiguous
abbreviations of those options. For example, @samp{rmdir
--ignore-fail-on-non-empty} can be invoked as @samp{rmdir
--ignore-fail} or even @samp{rmdir --i}. Ambiguous options, such as
@samp{ls --h}, are identified as such.
Some of these programs recognize the @option{--help} and @option{--version}
options only when one of them is the sole command line argument. For
these programs, abbreviations of the long options are not always recognized.
@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.
@item --
@opindex --
@cindex option delimiter
Delimit the option list. Later arguments, if any, are treated as
operands even if they begin with @samp{-}. For example, @samp{sort --
-r} reads from the file named @file{-r}.
@end table
@cindex standard input
@cindex standard output
A single @samp{-} operand is not really an option, though it looks like one. It
stands for a file operand, and some tools treat it as standard input, or as
standard output if that is clear from the context. For example, @samp{sort -}
reads from standard input, and is equivalent to plain @samp{sort}. Unless
otherwise specified, a @samp{-} can appear as any operand that requires a file
name.
@menu
Items shared between some programs:
* Backup options:: @option{-b} @option{-S}.
* Block size:: BLOCK_SIZE and @option{--block-size}.
* Signal specifications:: Specifying signals with @option{--signal}.
* Disambiguating names and IDs:: chgrp, chown, chroot, id: user and group syntax
* Random sources:: @option{--random-source}.
* Target directory:: Specifying a target directory.
* Trailing slashes:: @option{--strip-trailing-slashes}.
* Traversing symlinks:: @option{-H}, @option{-L}, or @option{-P}.
* Treating / specially:: @option{--preserve-root} and the converse.
* Special built-in utilities:: @command{break}, @command{:}, @dots{}
Items applicable to all programs:
* Exit status:: Indicating program success or failure.
* Floating point:: Floating point number representation.
* Standards conformance:: Conformance to the POSIX standard.
* Multi-call invocation:: Multi-call program invocation.
@end menu
@node Backup options
@section Backup options
@cindex backup options
Some GNU programs (at least @command{cp}, @command{install},
@command{ln}, and @command{mv}) optionally make backups of files
before writing new versions.
These options control the details of these backups. The options are also
briefly mentioned in the descriptions of the particular programs.
@table @samp
@item -b
@itemx --backup[=@var{method}]
@opindex -b
@opindex --backup
@vindex VERSION_CONTROL
@cindex backups, making
Make a backup of each file that would otherwise be overwritten or removed.
Without this option, the original versions are destroyed.
Use @var{method} to determine the type of backups to make.
When this option is used but @var{method} is not specified,
then the value of the @env{VERSION_CONTROL}
environment variable is used. And if @env{VERSION_CONTROL} is not set,
the default backup type is @samp{existing}.
Using @option{-b} is equivalent to using @option{--backup=existing};
@option{-b} does not accept any argument.
@vindex version-control @r{Emacs variable}
This option corresponds to the Emacs variable @samp{version-control};
the values for @var{method} are the same as those used in Emacs.
This option also accepts more descriptive names.
The valid @var{method}s are (unique abbreviations are accepted):
@table @samp
@item none
@itemx off
@opindex none @r{backup method}
Never make backups.
@item numbered
@itemx t
@opindex numbered @r{backup method}
Always make numbered backups.
@item existing
@itemx nil
@opindex existing @r{backup method}
Make numbered backups of files that already have them, simple backups
of the others.
@item simple
@itemx never
@opindex simple @r{backup method}
Always make simple backups. Do not confuse @samp{never} with @samp{none}.
@end table
@item -S @var{suffix}
@itemx --suffix=@var{suffix}
@opindex -S
@opindex --suffix
@cindex backup suffix
@vindex SIMPLE_BACKUP_SUFFIX
Append @var{suffix} to each backup file made with @option{-b}. If this
option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
set, the default is @samp{~}, just as in Emacs.
@end table
@node Block size
@section Block size
@cindex block size
Some GNU programs (at least @command{df}, @command{du}, and
@command{ls}) display sizes in ``blocks''. You can adjust the block size
and method of display to make sizes easier to read. The block size
used for display is independent of any file system block size.
Fractional block counts are rounded up to the nearest integer.
@opindex --block-size=@var{size}
@vindex BLOCKSIZE
@vindex BLOCK_SIZE
@vindex DF_BLOCK_SIZE
@vindex DU_BLOCK_SIZE
@vindex LS_BLOCK_SIZE
@vindex POSIXLY_CORRECT@r{, and block size}
The default block size is chosen by examining the following environment
variables in turn; the first one that is set determines the block size.
@table @code
@item DF_BLOCK_SIZE
This specifies the default block size for the @command{df} command.
Similarly, @env{DU_BLOCK_SIZE} specifies the default for @command{du} and
@env{LS_BLOCK_SIZE} for @command{ls}.
@item BLOCK_SIZE
This specifies the default block size for all three commands, if the
above command-specific environment variables are not set.
@item BLOCKSIZE
This specifies the default block size for all values that are normally
printed as blocks, if neither @env{BLOCK_SIZE} nor the above
command-specific environment variables are set. Unlike the other
environment variables, @env{BLOCKSIZE} does not affect values that are
normally printed as byte counts, e.g., the file sizes contained in
@code{ls -l} output.
@item POSIXLY_CORRECT
If neither @env{@var{command}_BLOCK_SIZE}, nor @env{BLOCK_SIZE}, nor
@env{BLOCKSIZE} is set, but this variable is set, the block size
defaults to 512.
@end table
If none of the above environment variables are set, the block size
currently defaults to 1024 bytes in most contexts, but this number may
change in the future. For @command{ls} file sizes, the block size
defaults to 1 byte.
@cindex human-readable output
@cindex SI output
A block size specification can be a positive integer specifying the number
of bytes per block, or it can be @code{human-readable} or @code{si} to
select a human-readable format. Integers may be followed by suffixes
that are upward compatible with the
@uref{http://www.bipm.org/en/publications/si-brochure/chapter3.html,
SI prefixes}
for decimal multiples and with the
@uref{https://physics.nist.gov/cuu/Units/binary.html, ISO/IEC 80000-13
(formerly IEC 60027-2) prefixes} for binary multiples.
With human-readable formats, output sizes are followed by a size letter
such as @samp{M} for megabytes. @code{BLOCK_SIZE=human-readable} uses
powers of 1024; @samp{M} stands for 1,048,576 bytes.
@code{BLOCK_SIZE=si} is similar, but uses powers of 1000 and appends
@samp{B}; @samp{MB} stands for 1,000,000 bytes.
@vindex LC_NUMERIC
A block size specification preceded by @samp{'} causes output sizes to
be displayed with thousands separators. The @env{LC_NUMERIC} locale
specifies the thousands separator and grouping. For example, in an
American English locale, @samp{--block-size="'1kB"} would cause a size
of 1234000 bytes to be displayed as @samp{1,234}. In the default C
locale, there is no thousands separator so a leading @samp{'} has no
effect.
An integer block size can be followed by a suffix to specify a
multiple of that size. A bare size letter,
or one followed by @samp{iB}, specifies
a multiple using powers of 1024. A size letter followed by @samp{B}
specifies powers of 1000 instead. For example, @samp{1M} and
@samp{1MiB} are equivalent to @samp{1048576}, whereas @samp{1MB} is
equivalent to @samp{1000000}.
A plain suffix without a preceding integer acts as if @samp{1} were
prepended, except that it causes a size indication to be appended to
the output. For example, @samp{--block-size="kB"} displays 3000 as
@samp{3kB}.
The following suffixes are defined. Large sizes like @code{1Q}
may be rejected by your computer due to limitations of its arithmetic.
@table @samp
@item kB
@cindex kilobyte, definition of
kilobyte: @math{10^3 = 1000}.
@item k
@itemx K
@itemx KiB
@cindex kibibyte, definition of
kibibyte: @math{2^{10} = 1024}. @samp{K} is special: the SI prefix is
@samp{k} and the ISO/IEC 80000-13 prefix is @samp{Ki}, but tradition and
POSIX use @samp{k} to mean @samp{KiB}.
@item MB