Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
pp (short for prepend) is a simple commandline utility to prepend text from standard input with text
given via commandline arguments. It has no flags or options. Compiling via the included Makefile or
manually with the `APPEND` preprocessor flag additionally gives you the commandline utility ap which
is functionally identical to pp except it appends to text from standard input.

Usage examples
	$ printf 'Hello\nWorld!\n' | pp '[LOG] '
	[LOG] Hello
	[LOG] World!
	$ pp [This  is some	'text] ' <text.txt
	[This is some text] Lorem ipsum dolor sit amet, consectetur adipiscing elit.
	[This is some text] Nam nec vestibulum urna.
	[This is some text] Nullam dapibus lacinia ullamcorper.
	[This is some text] Suspendisse lobortis ultricies elit eget rutrum.
	[This is some text] Pellentesque in maximus nisi.
	$ echo 'Lets try to ' | ap 'append some text!'
	Lets try to append some text!

A quirk with ap
The ap command will append given text to whatever is given through standard input. However it will
respect the trailing newline of input. That means that if input is given with a trailing newline, ap
will print its output with a trailing newline:

	$ echo 'Hello,' | ap ' World!'
	Hello, World!

If input is provided *without* a trailing newline however, a trailing newline will NOT be appended:

	$ echo -n 'Hello,' | ap ' World!'
	Hello, World!$ echo 'There was no newline!'
	There was no newline!

If you have input without a trailing newline and want to append a newline + some text, you could do
something like this:

	$ echo -n 'Hello,' | xargs -0 echo | ap ' World!'
	Hello, World!


Command line tools to prepend and append text.