Skip to content

ulfnic/cat.bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

cat.bash

Concatenate FILE(s) to stdout in pure BASH as an executable or sourceable script.

cat.bash [FILE]...
   With no FILE, or when FILE is -, read standard input.

Examples of Use

# Optional: source cat.bash to define cat.bash as a function for better performance.
source cat.bash
cat.bash '/path/to/file1' '/path/to/file2' > combined.txt
printf 'b' | cat.bash <(printf 'a') - <(printf 'c')
# stdout: abc
cat.bash < file-to-copy > copy-of-file
cat.bash <<-'EOF' > message.txt
	Hello from a heredoc
EOF

Proofs

Copying a binary:

cat.bash "$(which bash)" > /tmp/bash_copy
md5sum "$(which bash)" /tmp/bash_copy
# stdout:
# e979d93c05b74fb89fd21eb312f81d3d  /usr/bin/bash
# e979d93c05b74fb89fd21eb312f81d3d  /tmp/bash_copy

Copying null characters:

  printf '\0\0\0null\0\0\0characters\0\0\0' | cat.bash | sed 's/\o0/\\0/g'
# stdout: \0\0\0null\0\0\0characters\0\0\0

License

Licensed under Creative Commons, CC0 1.0 Universal. See LICENSE for details.

About

Concatenate files to stdout in pure BASH

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages