Miscellaneous Terminal commands

By Brian Tomasik

First published: . Last nontrivial update: .

Summary

This page lists various Terminal commands that someone might find useful at some point. They should generally work on Unix-based operating systems like Mac and Linux, though I haven't tested them very widely.

Contents

Count characters

To count the characters in a file name, such as foo.txt , enter

echo "foo.txt" | wc -m

and then subtract 1 from this number. (I assume the echoed string includes a newline character or something?)

Replace spaces with underscores

For example, to convert my text file.txt to my_text_file.txt , enter

echo "my text file.txt" | sed 's/ /_/g'

I got this command from flazzarini (2009).

Other