You are currently storing a set of names and then piping to sed
. When the glob is expanded this becomes a command on the form:
1butene.com xxxx | sed 's/.com//g'
Which is obviously not something allowed, as 1butene.com
is not a command by itself.
What you have to do is to
1) store the data,
2) perform the cleaning.
For this we have good news! You can perform Shell parameter expansion on arrays!
This way you can store the data in an array:
names=(*.com)
And then perform the replacement in all of them by just extracting its name, without the extension:
printf "%s\n" "${names[@]%.*}"
If you then want to change values of bash array elements without loop, just use the syntax
new_array=("${names[@]%.*}")
Sample:
$ touch a{1..3}.{sql,com}
$ com_names=(*com)
$ printf "%s\n" "${com_names[@]}"
a1.com
a2.com
a3.com
$ printf "%s\n" "${com_names[@]%.*}"
a1
a2
a3
b=("${com_names[@]%.*}") # assign to a new array
$ printf "%s\n" "${b[@]}"
a1
a2
a3