Reputation: 2043
> for filename in '*.sql'
> do
> echo "@some_string" >> $filename
> done
-bash: $filename: ambiguous redirect
when i try to append a constant to all files i get a error ambigous redirect.
Any idea how to solve this issue ?
Upvotes: 1
Views: 1140
Reputation: 4577
I'd use
#!/bin/bash
for filename in *.sql
do
echo "@some_string" >> "$filename"
done
The problem with your code is in
cat "@some_string"
since cat
expects a filename.
As stated by @c00kiemon5ter, you should also quote $filename
, since it could contain spaces.
Upvotes: 1
Reputation: 455440
Try:
for filename in *.sql
do
echo "@some_string" >> "$filename"
done
Upvotes: 3