1
> 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 ?

jhon.smith
  • 1,963
  • 6
  • 30
  • 56

2 Answers2

3

Try:

for filename in *.sql
do
echo "@some_string" >> "$filename"
done
codaddict
  • 445,704
  • 82
  • 492
  • 529
1

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.

Arialdo Martini
  • 4,427
  • 3
  • 31
  • 42