linux cut command with delimiter
Bash[Edit]
+
0
-
0
linux cut command with delimiter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21cut -d ':' -f 1 /path/to/file # opens selected file # splits each file row into columns by ":" # prints only field 1 (column 1) for each row # Practical example: cut -d ':' -f 1 /home/john/examples/file1.txt # Example input (file1.txt): # # row1_column1:row1_column2:row1_column3 # row2_column1:row2_column2:row2_column3 # row3_column1:row3_column2:row3_column3 # Example output: # # row1_column1 # row2_column1 # row3_column1
[Edit]
+
0
-
0
linux cut command with delimiter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21cut -d ':' -f 2-3 /path/to/file # opens selected file # splits each file row into columns by ":" # prints only fields from 2 to 3 (2 and 3 column) for each row # Practical example: cut -d ':' -f 1 /home/john/examples/file1.txt # Example input (file1.txt): # # row1_column1:row1_column2:row1_column3 # row2_column1:row2_column2:row2_column3 # row3_column1:row3_column2:row3_column3 # Example output: # # row1_column2:row1_column3 # row2_column2:row2_column3 # row3_column2:row3_column3
[Edit]
+
0
-
0
linux cut command with delimiter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22cat /path/to/file | cut -d ':' -f 1 # opens selected file with cat command # streams file content to cut command # splits each file row into columns by ":" # prints only field 1 (column 1) for each row # Practical example: cat home/john/examples/file1.txt | cut -d ':' -f 1 # Example input (file1.txt): # # row1_column1:row1_column2:row1_column3 # row2_column1:row2_column2:row2_column3 # row3_column1:row3_column2:row3_column3 # Example output: # # row1_column1 # row2_column1 # row3_column1