How to use "cat" command on "find" command's output?

You can do this with find alone using the -exec action:

find /location -size 1033c -exec cat {} +

{} will be expanded to the files found and + will enable us to read as many arguments as possible per invocation of cat, as cat can take multiple arguments.

If your find does not have the + extension or you want to read the files one by one:

find /location -size 1033c -exec cat {} \;

If you want to use any options of cat, do:

find /location -size 1033c -exec cat -n {} +
find /location -size 1033c -exec cat -n {} \;

Here I am using the -n option to get the line numbers.


Command Substitution

Another option is to use Command Substitution. Wrapping a command in $() will run the command and replace the command with its output.

cat $(find ./inhere -size 1033c 2> /dev/null)

will become

cat ./inhere/file1 .inhere/file3

This is more or less equivalent to using the older style of wrapping commands with back ticks:

cat `find ./inhere -size 1033c 2> /dev/null`

More details from the docs linked above

Bash performs the expansion by executing command in a subshell environment and replacing the command substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by $, `, or \. The first backquote not preceded by a backslash terminates the command substitution. When using the $(command) form, all characters between the parentheses make up the command; none are treated specially.

Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes.

If the substitution appears within double quotes, word splitting and filename expansion are not performed on the results.

See this other answer for some good examples of usage.

Tags:

Find

Cat