(more)

CIS241

System-Level Programming and Utilities

Additional Commands

Erik Fredericks, frederer@gvsu.edu
Fall 2025

Based on material provided by Erin Carrier, Austin Ferguson, and Katherine Bowers

CIS241 | Fredericks | F25 | 10-additional-commands

Some more helpful commands!

CIS241 | Fredericks | F25 | 10-additional-commands

wc - word count

Usage: wc <file>

  • Counts lines, words, bytes by default

To narrow it down:

  • wc -l <file>
    • -w for words, -b for bytes

Operates on stdin if no file specified!

CIS241 | Fredericks | F25 | 10-additional-commands

cut - grab columns (of delimited file)

"Delimited" - separated by a certain character

  • E.g., commas, tabs, spaces, etc.

Usage: cut <options> <file>

Options:

  • --delimiter=X - set delimiter
  • -f N - grab Nth delimited field (starting at 1)
  • --complement - ignore fields instead

Operates on stdin if no file specified!

https://www.geeksforgeeks.org/linux-unix/cut-command-linux-examples/

CIS241 | Fredericks | F25 | 10-additional-commands

tr - translate characters

Usage: tr <options> <set1> <set2>

Translates characters in set1 to set2

  • Operates on stdin

E.g.:

  • Replace a with b: tr a b < file
  • tr [:upper:] [:lower:] < file
  • tr -d '#' < file
CIS241 | Fredericks | F25 | 10-additional-commands

diff - check file differences

Usage: diff <options> <file1> <file2>

Shows ... file differences!

  • Very useful when comparing source files...
CIS241 | Fredericks | F25 | 10-additional-commands

wc -l *.txt | head -n -1 | sort -n - 1 prints all but the last 1 line sort number of lines grep -v garlic words.txt | wc -l

cut -d ',' -f 1-3 mmsa-icu-beds.csv cut -c 2, 5, 7 random_data_file.csv cut -c 1 random_data_file.csv | sort | uniq -c | sort -n (let's get the counts of the first letter - first get it, then sort, then count the uniq (check man), then sort (numeric))

-d deletes a character add aaaaaabbbbbbddddd to a file cat file_1 | tr -d [a,d] tr -d [:punct:] < words.txt