A command-line tool that wraps each line of input with a specified delimiter. Useful for formatting text data, preparing strings for code, or processing structured data.
- Wrap lines with any delimiter (default: double-quote)
- Support for hexadecimal delimiter notation
- Strip whitespace before wrapping
- Skip empty lines
- Escape delimiter characters within lines
- Read from files or STDIN (auto-detects piped input -
-is optional when reading from a pipe) - Write to files or STDOUT
- Process null-terminated input (compatible with
find -print0,xargs -0) - Automatically skip empty last lines
git clone https://github.com/jftuga/wrapline
cd wrapline
makeThis creates the wrapline executable in the current directory.
wrapline [options] <filename|->
-d <delimiter>- Delimiter to wrap lines with (default:")- Supports literal strings:
-d "|" - Supports hex notation:
-d 0x27for single quote
- Supports literal strings:
-s- Strip whitespace from lines before wrapping-e- Do not emit empty lines-escape- Escape delimiter characters within lines using backslash-o <file>- Write output to file instead of STDOUT-0- Read null-terminated records instead of newlines-v- Show version and exit
- Provide a filename to read from a file
- Use
-to read from STDIN - When data is piped into
wrapline, reading from STDIN is assumed automatically — the-argument is optional
Wrap lines with double quotes (default):
wrapline input.txtInput:
hello
world
Output:
"hello"
"world"
Wrap lines with single quotes:
wrapline -d "'" input.txtOutput:
'hello'
'world'
Use hexadecimal notation for delimiters (useful for special characters):
# Pipe character (0x7C = ASCII 124)
wrapline -d 0x7C input.txt
# Tab character (0x09)
wrapline -d 0x09 input.txtRemove leading and trailing whitespace before wrapping:
wrapline -s input.txtInput:
hello
world
Output:
"hello"
"world"
Don't output empty lines:
wrapline -e input.txtInput:
hello
world
Output:
"hello"
"world"
Escape delimiter characters found within lines:
wrapline -escape input.txtInput:
She said "hello" to me
Output:
"She said \"hello\" to me"
Write results to a file instead of STDOUT:
wrapline -d "|" input.txt -o output.txtwrapline automatically reads from piped input, so the - argument is optional:
echo "hello world" | wrapline
cat input.txt | wrapline -d "'" -sYou can still use - explicitly if preferred:
echo "hello world" | wrapline -Process null-terminated records (like find -print0):
find . -name "*.txt" -print0 | wrapline -0 -This is useful when filenames may contain newlines or special characters.
Combine multiple options for complex processing:
# Strip whitespace, skip empty lines, escape quotes, write to file
wrapline -s -e -escape -o output.txt input.txt
# Process null-terminated, custom delimiter, output to file
find . -type f -print0 | wrapline -0 -d "'" -o filelist.txt -wrapline can be used in conjunction with paste to produce a CSV-style list:
seq 1 10 | wrapline | paste -sd, -
"1","2","3","4","5","6","7","8","9","10"Convert a list of values into quoted strings for code:
wrapline cities.txtInput:
New York
Los Angeles
Chicago
Output:
"New York"
"Los Angeles"
"Chicago"
Wrap fields with quotes:
wrapline -escape data.txtProcess files found by find:
find /var/log -name "*.log" -print0 | wrapline -0 -d "'" -Strip whitespace and remove empty lines:
wrapline -s -e messy_data.txt -o clean_data.txt- Empty lines at the end of input are always skipped, regardless of flags
- When using
-e, all empty lines are skipped - The
-sflag strips whitespace before checking if a line is empty - Hexadecimal delimiter values must be prefixed with
0x - Without the
0xprefix, numeric strings are treated as literal delimiters wraplineautomatically detects piped input and does not require-when reading from a pipe