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; doneWhich 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; doneThe 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?
sed /PATTERN/SUB/ $VAR?
bash;sed;variable substitution
You can use a Here String with <<< syntax:ls | while IFS= read -r linedo  name=$(sed 's/\(.*\)/\1.jpg/' <<< $line) && mv $line $namedoneBe aware that it's not considered a good idea to parse the output of ls (nor to use unquoted variables).There is also a tool name rename (in case goal is simply to rename file):rename -n 's/$/.jpg/' *Remove the -n flag to change from preview to actual renaming.