I am renaming some files.
This works:
ls | while IFS= read -r line; do name=$(echo $line | sed -e 's/\(.*\)/\1.jpg/') && mv $line $name; done
Which is okay but I'd like to make it more concise, like:
ls | while IFS= read -r line; do name=$(sed -e 's/\(.*\)/\1.jpg/' $line) && mv $line $name; done
The latter example and various similar attempts pass the file into sed rather than the value of the variable.
Using ˋ$lineˋ and $($line) both result in an attempt to execute the file. While variations of "$line", 'line' with and without <, all lead to the file be read in. What is going on here? Can the $line variable be used directly with sed for this purpose?