@@ -56,38 +56,38 @@ DESCRIPTION
56
56
# ### <a name="various-counts"></a>Various counts
57
57
58
58
` ` ` bash
59
- $ cat sample.txt
59
+ $ cat sample.txt
60
60
Hello World
61
61
Good day
62
62
No doubt you like it too
63
63
Much ado about nothing
64
64
He he he
65
65
66
66
$ # by default, gives newline/word/byte count (in that order)
67
- $ wc sample.txt
67
+ $ wc sample.txt
68
68
5 17 78 sample.txt
69
69
70
70
$ # options to get individual numbers
71
- $ wc -l sample.txt
71
+ $ wc -l sample.txt
72
72
5 sample.txt
73
- $ wc -w sample.txt
73
+ $ wc -w sample.txt
74
74
17 sample.txt
75
- $ wc -c sample.txt
75
+ $ wc -c sample.txt
76
76
78 sample.txt
77
77
78
78
$ # use shell input redirection if filename is not needed
79
- $ wc -l < sample.txt
79
+ $ wc -l < sample.txt
80
80
5
81
81
` ` `
82
82
83
83
* multiple file input
84
84
* automatically displays total at end
85
85
86
86
` ` ` bash
87
- $ cat greeting.txt
87
+ $ cat greeting.txt
88
88
Hello there
89
89
Have a safe journey
90
- $ cat fruits.txt
90
+ $ cat fruits.txt
91
91
Fruit Price
92
92
apple 42
93
93
banana 31
@@ -104,7 +104,7 @@ $ wc *.txt
104
104
* use ` -L` to get length of longest line
105
105
106
106
` ` ` bash
107
- $ wc -L < sample.txt
107
+ $ wc -L < sample.txt
108
108
24
109
109
110
110
$ echo ' foo bar baz' | wc -L
@@ -280,7 +280,7 @@ $ du -S
280
280
281
281
```bash
282
282
$ # number of bytes
283
- $ stat -c %s words.txt
283
+ $ stat -c %s words.txt
284
284
938848
285
285
$ du -b words.txt
286
286
938848 words.txt
@@ -514,7 +514,7 @@ $ df -h --output=pcent,fstype | awk -F'%' 'NR>2 && $1>=40'
514
514
$ touch --version | head -n1
515
515
touch (GNU coreutils) 8.25
516
516
517
- $ man touch
517
+ $ man touch
518
518
TOUCH(1) User Commands TOUCH(1)
519
519
520
520
NAME
@@ -544,7 +544,7 @@ $ ls foo.txt
544
544
foo.txt
545
545
546
546
$ # use -c if new file shouldn' t be created
547
- $ rm foo.txt
547
+ $ rm foo.txt
548
548
$ touch -c foo.txt
549
549
$ ls foo.txt
550
550
ls: cannot access ' foo.txt' : No such file or directory
@@ -564,7 +564,7 @@ $ # last modification time
564
564
$ stat -c %y fruits.txt
565
565
2017-07-13 13:54:03.576055933 +0530
566
566
567
- $ touch fruits.txt
567
+ $ touch fruits.txt
568
568
$ stat -c %x fruits.txt
569
569
2017-07-21 10:11:44.241921229 +0530
570
570
$ stat -c %y fruits.txt
@@ -642,14 +642,14 @@ $ stat -c $'%x\n%y' story.txt
642
642
2017-06-24 12:59:53.316751651 +0530
643
643
$ # tmp.txt is temporary empty file
644
644
$ touch -r story.txt tmp.txt
645
- $ stat -c $'%x\n%y' tmp.txt
645
+ $ stat -c $'%x\n%y' tmp.txt
646
646
2017-06-24 13:00:31.773583923 +0530
647
647
2017-06-24 12:59:53.316751651 +0530
648
648
649
649
$ # after text processing, copy back the timestamps and remove temporary file
650
650
$ sed -i 's/cat/dog/g' story.txt
651
- $ touch -r tmp.txt story.txt && rm tmp.txt
652
- $ stat -c $'%x\n%y' story.txt
651
+ $ touch -r tmp.txt story.txt && rm tmp.txt
652
+ $ stat -c $'%x\n%y' story.txt
653
653
2017-06-24 13:00:31.773583923 +0530
654
654
2017-06-24 12:59:53.316751651 +0530
655
655
` ` `
@@ -699,10 +699,10 @@ DESCRIPTION
699
699
# ### <a name="file-type-examples"></a>File type examples
700
700
701
701
` ` ` bash
702
- $ file sample.txt
702
+ $ file sample.txt
703
703
sample.txt: ASCII text
704
704
$ # without file name in output
705
- $ file -b sample.txt
705
+ $ file -b sample.txt
706
706
ASCII text
707
707
708
708
$ printf 'hi👍\n' | file -
0 commit comments