If your shell is bash (amongst others), a shortcut for $(cat afile)
is $(< afile)
, so you’d write:
mycommand "$(< file.txt)"
Documented in the bash man page in the ‘Command Substitution’ section.
Alterately, have your command read from stdin, so: mycommand < file.txt
More Related Contents:
- What’s the magic of “-” (a dash) in command-line parameters?
- Does “argument list too long” restriction apply to shell builtins?
- GROUP BY/SUM from shell
- When should I wrap quotes around a shell variable?
- How to pass command output as multiple arguments to another command
- Get exit code of a background process
- Is there a way to change the environment variables of another process in Unix?
- Aborting a shell script if any command returns a non-zero value
- What does the number in parentheses shown after Unix command names in manpages mean?
- What does $@ mean in a shell script?
- Better way to rename files based on multiple patterns
- Forcing bash to expand variables in a string loaded from a file
- What is the difference between using `sh` and `source`?
- Setting environment variables in Linux using Bash
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Given two directory trees, how can I find out which files differ by content? [closed]
- How to run a shell script on a Unix console or Mac terminal?
- Using the passwd command from within a shell script
- What is the difference between “source script.sh” and “./script.sh”?
- How to print third column to last column?
- How to compare two DateTime strings and return difference in hours? (bash shell)
- Linux/Unix command to determine if process is running?
- How can I copy the output of a command directly into my clipboard?
- How to find directory of some command?
- Difference between shell and environment variables
- How do you filter out all unique lines in a file?
- How can I use xargs to copy files that have spaces and quotes in their names?
- Syntax error near unexpected token ‘then’
- Why doesn’t “sort file1 > file1” work?
- Find all files with name containing string [closed]