forked from andrewjkerr/security-cheatsheets
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Grant Ongers
committed
May 4, 2017
1 parent
04fd23b
commit ead9d8f
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# cut - select columns of text from each line of a file | ||
# if you're needing more comprehensive pattern-directed | ||
# scanning and processing, take a look at `awk` | ||
|
||
# Given a text file (file.txt) with the following text: | ||
# unix or linux os | ||
# is unix good os | ||
# is linux good os | ||
|
||
# cut will return the fourth element if given: | ||
cut -c4 file.txt | ||
x | ||
u | ||
l | ||
|
||
# cut will return the fourth and sixth element if given: | ||
cut -c4,6 file.txt | ||
xo | ||
ui | ||
ln | ||
|
||
# cut will return the fourth through seventh element if given: | ||
cut -c4-7 file.txt | ||
x or | ||
unix | ||
linu | ||
|
||
# to use cut like `awk` you could do the following to return the | ||
# second element, delimetered by a space: | ||
cut -d' ' -f2 file.txt | ||
or | ||
unix | ||
linux | ||
|
||
# in the same way as above you can modify -f to return varying results: | ||
cut -d' ' -f2,3 file.txt | ||
or linux | ||
unix good | ||
linux good | ||
|