Concept Flow - cut and paste
Start
Use 'cut' to extract columns
Use 'paste' to join columns
Output combined result
End
The flow shows extracting parts of text with 'cut', then joining them side-by-side with 'paste' to create combined output.
echo -e "a,b,c\nd,e,f" > file1.txt cut -d',' -f1 file1.txt > col1.txt cut -d',' -f3 file1.txt > col3.txt paste col1.txt col3.txt
| Step | Command | Action | Output |
|---|---|---|---|
| 1 | echo -e "a,b,c\nd,e,f" > file1.txt | Create file1.txt with two lines | |
| 2 | cut -d',' -f1 file1.txt > col1.txt | Extract first column (before first comma) | col1.txt contains: a d |
| 3 | cut -d',' -f3 file1.txt > col3.txt | Extract third column (after second comma) | col3.txt contains: c f |
| 4 | paste col1.txt col3.txt | Combine col1.txt and col3.txt side by side | a c d f |
| 5 | End | No more commands | Execution complete |
| Variable/File | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| file1.txt | does not exist | a,b,c d,e,f | a,b,c d,e,f | a,b,c d,e,f | a,b,c d,e,f | a,b,c d,e,f |
| col1.txt | does not exist | does not exist | a d | a d | a d | a d |
| col3.txt | does not exist | does not exist | does not exist | c f | c f | c f |
| paste output | none | none | none | none | a c d f | a c d f |
cut -d',' -fN file.txt extracts column N using comma as delimiter paste file1 file2 joins lines side by side with tabs Use cut to get columns, save to files, then paste to combine Output shows columns combined line by line Useful for splitting and merging text data