From 76d0ea3113933da30c1251e8c8b7016a677dfa42 Mon Sep 17 00:00:00 2001 From: johannst Date: Thu, 7 Nov 2024 22:05:24 +0000 Subject: deploy: 8c7f8b75acf4eb4fc0e8d606cffa4bcdae865606 --- cli/cut.html | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 cli/cut.html (limited to 'cli/cut.html') diff --git a/cli/cut.html b/cli/cut.html new file mode 100644 index 0000000..fa2e5ca --- /dev/null +++ b/cli/cut.html @@ -0,0 +1,243 @@ + + + + + + cut - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
+

cut(1)

+
# Remove sections from each line of files(s).
+cut OPT FILE [FILE]
+    -d DELIM     delimiter to tokenize
+    -f LIST      field selector
+    -c LIST      character selector
+
+

Example: only selected characters

+
echo 'aa bb cc dd' | cut -c "1-4"
+# aa b
+
+# Inverted selection.
+echo 'aa bb cc dd' | cut --complement -c "1-4"
+# b cc dd
+
+

Example: only selected fields

+

Fields in cut are indexed starting from 1 rather than 0.

+
# Fields 2 until 3.
+echo 'aa bb cc dd' | cut -d ' ' -f 2-3
+# bb cc
+
+# First field until the 2nd.
+echo 'aa bb cc dd' | cut -d ' ' -f -2
+# aa bb
+
+# Third field until the end.
+echo 'aa bb cc dd' | cut -d ' ' -f 3-
+# cc dd
+
+# If the number of tokens in a line is unkown but we want to remove the last 2
+# tokens we can use rev(1).
+echo 'aa bb cc dd' | rev | cut -d ' ' -f3- | rev
+# aa bb
+
+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ + -- cgit v1.2.3