I added a line to my .bashrc ages ago and I can't remember what I was trying to achieve. The line is:
bat () { echo "$(<"$@")" ; }
Now I've installed a different Linux distro and when I run it, I get the error:
bash: "$@": ambiguous redirect
Can anyone help me understand what I might have intended with this?
2 Answers
Looks like you were trying to implement `cat` using just Bash builtins! However, your function only accepts one argument. If you want to handle multiple files, you’d need to use a loop like this:
bat() { local f; for f in "$@"; do echo "$(<"$f")"; done; }
It seems like you were trying to create a version of `cat` that can handle multiple files, but it didn’t really work out as expected. Your function only processes one filename at a time, which is why you're running into that error when you try to pass multiple arguments.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically